Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:17

0001 #ifndef CommonTools_Utils_ExpressionBinaryOperatorSetter_h
0002 #define CommonTools_Utils_ExpressionBinaryOperatorSetter_h
0003 /* \class reco::parser::ExpressionBinaryOperator
0004  *
0005  * Binary operator expression setter
0006  *
0007  * \author original version: Chris Jones, Cornell, 
0008  *         adapted by Luca Lista, INFN
0009  *
0010  * \version $Revision: 1.2 $
0011  *
0012  */
0013 #include "CommonTools/Utils/interface/parser/ExpressionBinaryOperator.h"
0014 #include "CommonTools/Utils/interface/parser/ExpressionStack.h"
0015 #include <cmath>
0016 
0017 namespace reco {
0018   namespace parser {
0019 
0020     template <typename T>
0021     struct power_of {
0022       T operator()(T lhs, T rhs) const { return pow(lhs, rhs); }
0023     };
0024 
0025     template <typename T>
0026     struct int_div_remainder {
0027       T operator()(T lhs, T rhs) const { return int(lhs) % int(rhs); }
0028     };
0029 
0030     template <typename Op>
0031     struct ExpressionBinaryOperatorSetter {
0032       ExpressionBinaryOperatorSetter(ExpressionStack& stack) : stack_(stack) {}
0033       void operator()(const char*, const char*) const {
0034         stack_.push_back(ExpressionPtr(new ExpressionBinaryOperator<Op>(stack_)));
0035       }
0036 
0037     private:
0038       ExpressionStack& stack_;
0039     };
0040   }  // namespace parser
0041 }  // namespace reco
0042 
0043 #endif