CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CommonTools/Utils/src/FunctionSetter.h

Go to the documentation of this file.
00001 #ifndef CommonTools_Utils_FunctionSetter_h
00002 #define CommonTools_Utils_FunctionSetter_h
00003 /* \class reco::parser::FunctionSetter
00004  *
00005  * Function setter
00006  *
00007  * \author Luca Lista, INFN
00008  *
00009  * \version $Revision: 1.2 $
00010  *
00011  */
00012 #include "CommonTools/Utils/src/Function.h"
00013 #include "CommonTools/Utils/src/FunctionStack.h"
00014 
00015 namespace reco {
00016   namespace parser {    
00017     struct FunctionSetter {
00018       FunctionSetter(Function fun, FunctionStack& stack):
00019         fun_(fun), stack_(stack) {}
00020       
00021       void operator()(const char *, const char *) const { 
00022 #ifdef BOOST_SPIRIT_DEBUG 
00023         BOOST_SPIRIT_DEBUG_OUT << "pushing math function: " << functionNames[ fun_ ] << std::endl;
00024 #endif
00025         stack_.push_back(fun_); 
00026       }
00027     private:
00028       Function fun_;
00029       FunctionStack & stack_;
00030     };
00031 
00032     struct FunctionSetterCommit { 
00033         FunctionSetterCommit(FunctionStack& stackFrom, FunctionStack& stackTo):
00034             from_(stackFrom), to_(stackTo) {}
00035         void operator()(const char &) const { 
00036             to_.push_back(from_.back());
00037             from_.clear();
00038         }
00039         private:
00040             FunctionStack & from_;
00041             FunctionStack & to_;
00042     };
00043   }
00044 }
00045 
00046 #endif