CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CommonTools/Utils/src/ExpressionCondition.h

Go to the documentation of this file.
00001 #ifndef CommonTools_Utils_ExpressionCondition_h
00002 #define CommonTools_Utils_ExpressionCondition_h
00003 /* \class reco::parser::ExpressionCondition
00004  *
00005  * Unary Operator expression
00006  *
00007  * \author original version: Chris Jones, Cornell, 
00008  *         adapted by Luca Lista, INFN
00009  *
00010  * \version $Revision: 1.3 $
00011  *
00012  */
00013 #include "CommonTools/Utils/src/ExpressionBase.h"
00014 #include "CommonTools/Utils/src/SelectorBase.h"
00015 #include "CommonTools/Utils/src/ExpressionStack.h"
00016 
00017 namespace reco {
00018   namespace parser {
00019     struct ExpressionCondition : public ExpressionBase {
00020       virtual double value(const edm::ObjectWithDict& o) const { 
00021         return (*cond_)(o) ? true_->value(o) : false_->value(o);
00022       }
00023       ExpressionCondition(ExpressionStack & expStack, SelectorStack & selStack) { 
00024         false_ = expStack.back(); expStack.pop_back();
00025         true_  = expStack.back(); expStack.pop_back();
00026         cond_  = selStack.back(); selStack.pop_back();
00027       }
00028       private:
00029       ExpressionPtr true_, false_;
00030       SelectorPtr cond_;
00031     };
00032   }
00033 }
00034 
00035 #endif