CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
reco::parser::SingleInvoker Struct Reference

#include <MethodInvoker.h>

Inheritance diagram for reco::parser::SingleInvoker:

Public Member Functions

std::pair< edm::ObjectWithDict,
bool > 
invoke (const edm::ObjectWithDict &o, std::vector< edm::ObjectWithDict > &v) const
 
double retToDouble (const edm::ObjectWithDict &) const
 convert the output of invoke to a double, if possible More...
 
 SingleInvoker (const edm::TypeWithDict &, const std::string &name, const std::vector< AnyMethodArgument > &args)
 
void throwFailedConversion (const edm::ObjectWithDict &) const
 
 ~SingleInvoker ()
 

Private Attributes

std::vector< MethodInvokerinvokers_
 
bool isRefGet_
 true if this invoker just pops out a ref and returns (ref.get(), false) More...
 
method::TypeCode retType_
 
edm::ObjectWithDict storage_
 
bool storageNeedsDestructor_
 

Detailed Description

A bigger brother of the MethodInvoker:

Definition at line 69 of file MethodInvoker.h.

Constructor & Destructor Documentation

SingleInvoker::SingleInvoker ( const edm::TypeWithDict type,
const std::string &  name,
const std::vector< AnyMethodArgument > &  args 
)

Definition at line 240 of file MethodInvoker.cc.

References invokers_, isRefGet_, reco::parser::ExpressionVar::makeStorage(), reco::parser::MethodSetter::push(), retType_, storage_, storageNeedsDestructor_, and reco::typeCode().

242 {
243  TypeStack typeStack(1, type);
244  LazyMethodStack dummy;
245  MethodArgumentStack dummy2;
246  MethodSetter setter(invokers_, dummy, typeStack, dummy2, false);
247  isRefGet_ = !setter.push(name, args, "LazyInvoker dynamic resolution", false);
248  //std::cerr << "SingleInvoker on type " << type.qualifiedName() <<
249  // ", name " << name << (isRefGet_ ? " is just a ref.get " : " is real") <<
250  // std::endl;
251  if (invokers_.front().isFunction()) {
252  edm::TypeWithDict retType = invokers_.front().method().finalReturnType();
254  }
255  else {
257  storageNeedsDestructor_ = false;
258  }
259  // typeStack[0] = type of self
260  // typeStack[1] = type of ret
261  retType_ = reco::typeCode(typeStack[1]);
262 }
method::TypeCode retType_
Definition: MethodInvoker.h:71
static bool makeStorage(edm::ObjectWithDict &obj, const edm::TypeWithDict &retType)
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:76
std::vector< edm::TypeWithDict > TypeStack
Definition: TypeStack.h:17
std::vector< AnyMethodArgument > MethodArgumentStack
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:73
TypeCode typeCode(const edm::TypeWithDict &t)
Definition: returnType.cc:44
std::vector< LazyInvoker > LazyMethodStack
Definition: MethodStack.h:18
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:72
SingleInvoker::~SingleInvoker ( )

Definition at line 265 of file MethodInvoker.cc.

References reco::parser::ExpressionVar::delStorage(), and storage_.

266 {
268 }
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:73
static void delStorage(edm::ObjectWithDict &)

Member Function Documentation

pair< edm::ObjectWithDict, bool > SingleInvoker::invoke ( const edm::ObjectWithDict o,
std::vector< edm::ObjectWithDict > &  v 
) const

If the member is found in object o, evaluate and return (value,true) If the member is not found but o is a Ref/RefToBase/Ptr, (return o.get(), false) the actual edm::ObjectWithDict where the result is stored will be pushed in vector so that, if needed, its destructor can be called

Definition at line 272 of file MethodInvoker.cc.

References invokers_, isRefGet_, run_regression::ret, storage_, and storageNeedsDestructor_.

Referenced by reco::parser::LazyInvoker::invoke(), and reco::parser::LazyInvoker::invokeLast().

273 {
274  // std::cerr << "[SingleInvoker::invoke] member " <<
275  // invokers_.front().method().qualifiedName() <<
276  // " of type " <<
277  // o.typeOf().qualifiedName() <<
278  // (!isRefGet_ ? " is one shot" : " needs another round") <<
279  // std::endl;
280  pair<edm::ObjectWithDict, bool>
281  ret(invokers_.front().invoke(o, storage_), !isRefGet_);
283  //std::cerr << "Storage type: " << storage_.typeOf().qualifiedName() <<
284  // ", I have to call the destructor." << std::endl;
285  v.push_back(storage_);
286  }
287  return ret;
288 }
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:76
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:73
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:72
double SingleInvoker::retToDouble ( const edm::ObjectWithDict o) const

convert the output of invoke to a double, if possible

Definition at line 292 of file MethodInvoker.cc.

References reco::parser::ExpressionVar::isValidReturnType(), reco::parser::ExpressionVar::objToDouble(), retType_, and throwFailedConversion().

Referenced by reco::parser::LazyInvoker::invokeLast().

293 {
296  }
298 }
method::TypeCode retType_
Definition: MethodInvoker.h:71
static double objToDouble(const edm::ObjectWithDict &obj, method::TypeCode type)
static bool isValidReturnType(method::TypeCode)
void throwFailedConversion(const edm::ObjectWithDict &) const
void SingleInvoker::throwFailedConversion ( const edm::ObjectWithDict o) const

Definition at line 302 of file MethodInvoker.cc.

References edm::errors::Configuration, Exception, invokers_, edm::TypeWithDict::qualifiedName(), and edm::ObjectWithDict::typeOf().

Referenced by retToDouble().

303 {
305  << "member \"" << invokers_.back().methodName()
306  << "\" return type is \"" << invokers_.back().returnTypeName()
307  << "\" retured a \"" << o.typeOf().qualifiedName()
308  << "\" which is not convertible to double.";
309 }
std::string qualifiedName() const
TypeWithDict typeOf() const
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:72

Member Data Documentation

std::vector<MethodInvoker> reco::parser::SingleInvoker::invokers_
private

Definition at line 72 of file MethodInvoker.h.

Referenced by invoke(), SingleInvoker(), and throwFailedConversion().

bool reco::parser::SingleInvoker::isRefGet_
private

true if this invoker just pops out a ref and returns (ref.get(), false)

Definition at line 76 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().

method::TypeCode reco::parser::SingleInvoker::retType_
private

Definition at line 71 of file MethodInvoker.h.

Referenced by retToDouble(), and SingleInvoker().

edm::ObjectWithDict reco::parser::SingleInvoker::storage_
mutableprivate

Definition at line 73 of file MethodInvoker.h.

Referenced by invoke(), SingleInvoker(), and ~SingleInvoker().

bool reco::parser::SingleInvoker::storageNeedsDestructor_
private

Definition at line 74 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().