SelectorBase.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_SelectorBase_h
2 #define art_Framework_Principal_SelectorBase_h
3 
4 // ==========================================================================
5 // Selector: Base class for all "selector" objects, used to select
6 // EDProducts based on information in the associated Provenance.
7 //
8 // Developers who make their own Selectors should inherit from SelectorBase.
9 //
10 // The 'match' function should return true to denote a successful
11 // match with the product described by the provided BranchDescription
12 // object. Otherwise, the function should return false. Upon
13 // returning true, the corresponding product becomes a candidate for
14 // product retrieval.
15 //
16 // The 'print' function is called whenever a product selection fails.
17 // Selector authors should return a string with the characteristics of
18 // the selector. The string will be encapsulated by an error message
19 // that states the selection criteria were not satisfied during
20 // product lookup.
21 //
22 // For a selector that matches against (e.g.) the product ID, the
23 // recommended use pattern is:
24 //
25 // return indent + "Product ID: " << product_id;
26 //
27 // ==========================================================================
28 
30 
31 #include <string>
32 
33 namespace art {
34  class BranchDescription;
35 }
36 
38 public:
39  virtual ~SelectorBase() = default;
40  bool
41  match(BranchDescription const& p) const
42  {
43  return doMatch(p);
44  }
45 
47  print(std::string const& indent) const
48  {
49  return doPrint(indent);
50  }
51 
52 private:
53  virtual bool doMatch(BranchDescription const& p) const = 0;
54  virtual std::string doPrint(std::string const& indent) const = 0;
55 };
56 
57 #endif /* art_Framework_Principal_SelectorBase_h */
58 
59 // Local Variables:
60 // mode: c++
61 // End:
std::string string
Definition: nybbler.cc:12
virtual ~SelectorBase()=default
std::string print(std::string const &indent) const
Definition: SelectorBase.h:47
virtual bool doMatch(BranchDescription const &p) const =0
p
Definition: test.py:223
virtual std::string doPrint(std::string const &indent) const =0
bool match(BranchDescription const &p) const
Definition: SelectorBase.h:41