CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/HLTcore/interface/TriggerExpressionOperators.h

Go to the documentation of this file.
00001 #ifndef HLTrigger_HLTfilters_TriggerExpressionOperators_h
00002 #define HLTrigger_HLTfilters_TriggerExpressionOperators_h
00003 
00004 #include <boost/scoped_ptr.hpp>
00005 #include "HLTrigger/HLTcore/interface/TriggerExpressionEvaluator.h"
00006 
00007 namespace triggerExpression {
00008 
00009 // abstract unary operator
00010 class UnaryOperator : public Evaluator {
00011 public:
00012   UnaryOperator(Evaluator * arg) :
00013     m_arg(arg)
00014   { }
00015 
00016   // initialize the depending modules
00017   void init(const Data & data) { 
00018     m_arg->init(data);
00019   }
00020 
00021 protected:
00022   boost::scoped_ptr<Evaluator> m_arg;
00023 };
00024 
00025 // abstract binary operator
00026 class BinaryOperator : public Evaluator {
00027 public:
00028   BinaryOperator(Evaluator * arg1, Evaluator * arg2) :
00029     m_arg1(arg1),
00030     m_arg2(arg2)
00031   { }
00032 
00033   // initialize the depending modules
00034   void init(const Data & data) { 
00035     m_arg1->init(data);
00036     m_arg2->init(data);
00037   }
00038 
00039 protected:
00040   boost::scoped_ptr<Evaluator> m_arg1;
00041   boost::scoped_ptr<Evaluator> m_arg2;
00042 };
00043 
00044 
00045 // concrete operators
00046 
00047 class OperatorNot : public UnaryOperator {
00048 public:
00049   OperatorNot(Evaluator * arg) :
00050     UnaryOperator(arg)
00051   { }
00052 
00053   bool operator()(const Data & data) const {
00054     return not (*m_arg)(data);
00055   }
00056   
00057   void dump(std::ostream & out) const {
00058     out << "NOT ";
00059     m_arg->dump(out);
00060   }
00061 };
00062 
00063 class OperatorAnd : public BinaryOperator {
00064 public:
00065   OperatorAnd(Evaluator * arg1, Evaluator * arg2) :
00066     BinaryOperator(arg1, arg2)
00067   { }
00068 
00069   bool operator()(const Data & data) const {
00070     // force the execution af both arguments, otherwise precalers won't work properly
00071     bool r1 = (*m_arg1)(data);
00072     bool r2 = (*m_arg2)(data);
00073     return r1 and r2;
00074   }
00075   
00076   void dump(std::ostream & out) const {
00077     m_arg1->dump(out);
00078     out << " AND ";
00079     m_arg2->dump(out);
00080   }
00081 };
00082 
00083 class OperatorOr : public BinaryOperator {
00084 public:
00085   OperatorOr(Evaluator * arg1, Evaluator * arg2) :
00086     BinaryOperator(arg1, arg2)
00087   { }
00088 
00089   bool operator()(const Data & data) const {
00090     // force the execution af both arguments, otherwise precalers won't work properly
00091     bool r1 = (*m_arg1)(data);
00092     bool r2 = (*m_arg2)(data);
00093     return r1 or r2;
00094   }
00095   
00096   void dump(std::ostream & out) const {
00097     m_arg1->dump(out);
00098     out << " OR ";
00099     m_arg2->dump(out);
00100   }
00101 };
00102 
00103 class OperatorXor : public BinaryOperator {
00104 public:
00105   OperatorXor(Evaluator * arg1, Evaluator * arg2) :
00106     BinaryOperator(arg1, arg2)
00107   { }
00108 
00109   bool operator()(const Data & data) const {
00110     // force the execution af both arguments, otherwise precalers won't work properly
00111     bool r1 = (*m_arg1)(data);
00112     bool r2 = (*m_arg2)(data);
00113     return r1 xor r2;
00114   }
00115   
00116   void dump(std::ostream & out) const {
00117     m_arg1->dump(out);
00118     out << " XOR ";
00119     m_arg2->dump(out);
00120   }
00121 };
00122 
00123 } // namespace triggerExpression
00124 
00125 #endif // HLTrigger_HLTfilters_TriggerExpressionOperators_h