CMS 3D CMS Logo

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) : type_(typeid(T)) {
18  if (!reco::parser::expressionParser<T>(expr, expr_, lazy)) {
19  throw edm::Exception(edm::errors::Configuration, "failed to parse \"" + expr + "\"");
20  }
21  }
23  double operator()(const T &t) const {
24  edm::ObjectWithDict o(type_, const_cast<T *>(&t));
25  return expr_->value(o);
26  }
27 
28 private:
31 };
32 
33 template <typename Object>
35 public:
38 
39  bool operator()(const Object *o1, const Object *o2) { return (*f_)(*o1) > (*f_)(*o2); }
40 
41 private:
43 };
44 
45 #endif
std::shared_ptr< ExpressionBase > ExpressionPtr
StringObjectFunction(const reco::parser::ExpressionPtr &expr)
double f[11][100]
StringObjectFunction(const std::string &expr, bool lazy=DefaultLazyness)
edm::TypeWithDict type_
bool operator()(const Object *o1, const Object *o2)
reco::parser::ExpressionPtr expr_
StringObjectFunction< Object > * f_
long double T
double operator()(const T &t) const
sortByStringFunction(StringObjectFunction< Object > *f)