CMS 3D CMS Logo

TriggerExpressionOperators.h
Go to the documentation of this file.
1 #ifndef HLTrigger_HLTfilters_TriggerExpressionOperators_h
2 #define HLTrigger_HLTfilters_TriggerExpressionOperators_h
3 
4 #include <memory>
6 
7 namespace triggerExpression {
8 
9  // abstract unary operator
10  class UnaryOperator : public Evaluator {
11  public:
13 
14  // initialize the depending modules
15  void init(const Data& data) override { m_arg->init(data); }
16 
17  // return the patterns from the depending modules
18  std::vector<std::string> patterns() const override { return m_arg->patterns(); }
19 
20  protected:
21  std::unique_ptr<Evaluator> m_arg;
22  };
23 
24  // abstract binary operator
25  class BinaryOperator : public Evaluator {
26  public:
27  BinaryOperator(Evaluator* arg1, Evaluator* arg2) : m_arg1(arg1), m_arg2(arg2) {}
28 
29  // initialize the depending modules
30  void init(const Data& data) override {
31  m_arg1->init(data);
32  m_arg2->init(data);
33  }
34 
35  // return the patterns from the depending modules
36  std::vector<std::string> patterns() const override {
37  std::vector<std::string> patterns = m_arg1->patterns();
38  auto patterns2 = m_arg2->patterns();
39  patterns.insert(
40  patterns.end(), std::make_move_iterator(patterns2.begin()), std::make_move_iterator(patterns2.end()));
41  return patterns;
42  }
43 
44  protected:
45  std::unique_ptr<Evaluator> m_arg1;
46  std::unique_ptr<Evaluator> m_arg2;
47  };
48 
49  // concrete operators
50 
51  class OperatorNot : public UnaryOperator {
52  public:
54 
55  bool operator()(const Data& data) const override { return not(*m_arg)(data); }
56 
57  void dump(std::ostream& out) const override {
58  out << "NOT ";
59  m_arg->dump(out);
60  }
61  };
62 
63  class OperatorAnd : public BinaryOperator {
64  public:
65  OperatorAnd(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
66 
67  bool operator()(const Data& data) const override {
68  // force the execution af both arguments, otherwise precalers won't work properly
69  bool r1 = (*m_arg1)(data);
70  bool r2 = (*m_arg2)(data);
71  return r1 and r2;
72  }
73 
74  void dump(std::ostream& out) const override {
75  m_arg1->dump(out);
76  out << " AND ";
77  m_arg2->dump(out);
78  }
79  };
80 
81  class OperatorOr : public BinaryOperator {
82  public:
83  OperatorOr(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
84 
85  bool operator()(const Data& data) const override {
86  // force the execution af both arguments, otherwise precalers won't work properly
87  bool r1 = (*m_arg1)(data);
88  bool r2 = (*m_arg2)(data);
89  return r1 or r2;
90  }
91 
92  void dump(std::ostream& out) const override {
93  m_arg1->dump(out);
94  out << " OR ";
95  m_arg2->dump(out);
96  }
97  };
98 
99  class OperatorXor : public BinaryOperator {
100  public:
101  OperatorXor(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
102 
103  bool operator()(const Data& data) const override {
104  // force the execution af both arguments, otherwise precalers won't work properly
105  bool r1 = (*m_arg1)(data);
106  bool r2 = (*m_arg2)(data);
107  return r1 xor r2;
108  }
109 
110  void dump(std::ostream& out) const override {
111  m_arg1->dump(out);
112  out << " XOR ";
113  m_arg2->dump(out);
114  }
115  };
116 
117 } // namespace triggerExpression
118 
119 #endif // HLTrigger_HLTfilters_TriggerExpressionOperators_h
bool operator()(const Data &data) const override
std::vector< std::string > patterns() const override
void dump(std::ostream &out) const override
void dump(std::ostream &out) const override
void init(const Data &data) override
BinaryOperator(Evaluator *arg1, Evaluator *arg2)
OperatorOr(Evaluator *arg1, Evaluator *arg2)
bool operator()(const Data &data) const override
A arg
Definition: Factorize.h:31
void init(const Data &data) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void dump(std::ostream &out) const override
void dump(std::ostream &out) const override
bool operator()(const Data &data) const override
bool operator()(const Data &data) const override
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
OperatorXor(Evaluator *arg1, Evaluator *arg2)
std::vector< std::string > patterns() const override
OperatorAnd(Evaluator *arg1, Evaluator *arg2)