CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/FWCore/Framework/interface/GroupSelectorRules.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_GroupSelectorRules_h
00002 #define FWCore_Framework_GroupSelectorRules_h
00003 
00005 //
00006 // Class GroupSelectorRules. Class for rules to select specific groups in event.
00007 //
00008 // Author: Bill Tanenbaum, Marc Paterno
00009 //
00011 
00012 #include <iosfwd>
00013 #include <string>
00014 #include <vector>
00015 
00016 #include <boost/regex.hpp>
00017 
00018 namespace edm {
00019   class BranchDescription;
00020   class GroupSelector;
00021   class ParameterSet;
00022   class ParameterSetDescription;
00023 
00024   class GroupSelectorRules {
00025   public:
00026     GroupSelectorRules(ParameterSet const& pset, std::string const& parameterName, std::string const& parameterOwnerName);
00027     //--------------------------------------------------
00028     // BranchSelectState is a struct which associates a BranchDescription
00029     // (*desc) with a bool indicating whether or not the branch with
00030     // that name is to be selected.  Note that desc may not be null.
00031     struct BranchSelectState {
00032       edm::BranchDescription const* desc;
00033       bool                          selectMe;
00034   
00035       // N.B.: We assume bd is not null.
00036       explicit BranchSelectState (edm::BranchDescription const* bd) : 
00037         desc(bd), 
00038         selectMe(false)
00039       { }
00040     };
00041   
00042     void applyToAll(std::vector<BranchSelectState>& branchstates) const;
00043 
00044     bool keepAll() const {return keepAll_;}
00045 
00046     static void fillDescription(ParameterSetDescription& desc, char const* parameterName);
00047 
00048   private:
00049     class Rule {
00050     public:
00051       Rule(std::string const& s, std::string const& parameterName, std::string const& owner);
00052   
00053       // Apply the rule to all the given branch states. This may modify
00054       // the given branch states.
00055       void applyToAll(std::vector<BranchSelectState>& branchstates) const;
00056   
00057       // Apply the rule to the given BranchDescription. The return value
00058       // is the value to which the 'select bit' should be set, according
00059       // to application of this rule.
00060       //bool applyToOne(BranchDescription const* branch) const;
00061   
00062       // If this rule applies to the given BranchDescription, then
00063       // modify 'result' to match the rule's select flag. If the rule does
00064       // not apply, do not modify 'result'.
00065       void applyToOne(BranchDescription const* branch, bool& result) const;
00066   
00067       // Return the answer to the question: "Does the rule apply to this
00068       // BranchDescription?"
00069       bool appliesTo(BranchDescription const* branch) const;
00070   
00071     private:
00072       // selectflag_ carries the value to which we should set the 'select
00073       // bit' if this rule matches.
00074       bool   selectflag_;
00075       boost::regex productType_;
00076       boost::regex moduleLabel_;
00077       boost::regex instanceName_;
00078       boost::regex processName_;
00079     };
00080   private:
00081     std::vector<Rule> rules_;
00082     std::string parameterName_;
00083     std::string parameterOwnerName_;
00084     bool keepAll_;
00085   };
00086 
00087 } // namespace edm
00088 
00089 
00090 
00091 #endif