CMS 3D CMS Logo

GroupSelectorRules.h

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

Generated on Tue Jun 9 17:35:41 2009 for CMSSW by  doxygen 1.5.4