test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StringObjectFunction.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_StringObjectFunction_h
2 #define CommonTools_Utils_StringObjectFunction_h
3 /* \class StringCutObjectSelector
4  *
5  * \author Luca Lista, INFN
6  *
7  * $Id: StringObjectFunction.h,v 1.4 2012/06/26 21:09:37 wmtan Exp $
8  */
14 
15 template<typename T, bool DefaultLazyness=false>
17  StringObjectFunction(const std::string & expr, bool lazy=DefaultLazyness) :
18  type_(typeid(T)) {
19  if(! reco::parser::expressionParser<T>(expr, expr_, lazy)) {
21  "failed to parse \"" + expr + "\"");
22  }
23  }
25  expr_(expr),
26  type_(typeid(T)) {
27  }
28  double operator()(const T & t) const {
29  edm::ObjectWithDict o(type_, const_cast<T *>(& t));
30  return expr_->value(o);
31  }
32 
33 private:
36 };
37 
38 #endif
boost::shared_ptr< ExpressionBase > ExpressionPtr
StringObjectFunction(const reco::parser::ExpressionPtr &expr)
StringObjectFunction(const std::string &expr, bool lazy=DefaultLazyness)
edm::TypeWithDict type_
reco::parser::ExpressionPtr expr_
long double T
double operator()(const T &t) const