CMS 3D CMS Logo

ProductSelectorRules.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProductSelectorRules_h
2 #define FWCore_Framework_ProductSelectorRules_h
3 
5 //
6 // Class ProductSelectorRules. Class for rules to select specific products in event.
7 //
8 // Author: Bill Tanenbaum, Marc Paterno
9 //
11 
12 #include <iosfwd>
13 #include <string>
14 #include <vector>
15 
16 #include <regex>
17 
18 namespace edm {
19  class BranchDescription;
20  class ProductSelector;
21  class ParameterSet;
23 
25  public:
27  std::string const& parameterName,
28  std::string const& parameterOwnerName);
29  //--------------------------------------------------
30  // BranchSelectState is a struct which associates a BranchDescription
31  // (*desc) with a bool indicating whether or not the branch with
32  // that name is to be selected. Note that desc may not be null.
35  bool selectMe;
36 
37  // N.B.: We assume bd is not null.
38  explicit BranchSelectState(edm::BranchDescription const* bd) : desc(bd), selectMe(false) {}
39  };
40 
41  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
42 
43  bool keepAll() const { return keepAll_; }
44 
46  char const* parameterName,
47  std::vector<std::string> const& defaultStrings = defaultSelectionStrings());
48 
49  static const std::vector<std::string>& defaultSelectionStrings();
50 
51  private:
52  class Rule {
53  public:
54  Rule(std::string const& s, std::string const& parameterName, std::string const& owner);
55 
56  // Apply the rule to all the given branch states. This may modify
57  // the given branch states.
58  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
59 
60  // Apply the rule to the given BranchDescription. The return value
61  // is the value to which the 'select bit' should be set, according
62  // to application of this rule.
63  //bool applyToOne(BranchDescription const* branch) const;
64 
65  // If this rule applies to the given BranchDescription, then
66  // modify 'result' to match the rule's select flag. If the rule does
67  // not apply, do not modify 'result'.
68  void applyToOne(BranchDescription const* branch, bool& result) const;
69 
70  // Return the answer to the question: "Does the rule apply to this
71  // BranchDescription?"
72  bool appliesTo(BranchDescription const* branch) const;
73 
74  private:
75  // selectflag_ carries the value to which we should set the 'select
76  // bit' if this rule matches.
78  std::regex productType_;
79  std::regex moduleLabel_;
80  std::regex instanceName_;
81  std::regex processName_;
82  };
83 
84  private:
85  std::vector<Rule> rules_;
88  bool keepAll_;
89  };
90 
91 } // namespace edm
92 
93 #endif
static const std::vector< std::string > & defaultSelectionStrings()
static void fillDescription(ParameterSetDescription &desc, char const *parameterName, std::vector< std::string > const &defaultStrings=defaultSelectionStrings())
void applyToAll(std::vector< BranchSelectState > &branchstates) const
ProductSelectorRules(ParameterSet const &pset, std::string const &parameterName, std::string const &parameterOwnerName)
BranchSelectState(edm::BranchDescription const *bd)
HLT enums.