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 &o) const
 
 SingleInvoker (const edm::TypeWithDict &t, const std::string &name, const std::vector< AnyMethodArgument > &args)
 
void throwFailedConversion (const edm::ObjectWithDict &o) 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 47 of file MethodInvoker.h.

Constructor & Destructor Documentation

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

Definition at line 168 of file MethodInvoker.cc.

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

171 {
172  TypeStack typeStack(1, type);
173  LazyMethodStack dummy;
174  MethodArgumentStack dummy2;
175  MethodSetter setter(invokers_, dummy, typeStack, dummy2, false);
176  isRefGet_ = !setter.push(name, args, "LazyInvoker dynamic resolution", false);
177  //std::cerr << "SingleInvoker on type " << type.qualifiedName() << ", name " << name << (isRefGet_ ? " is just a ref.get " : " is real") << std::endl;
178  if(invokers_.front().isFunction()) {
179  edm::TypeWithDict retType = invokers_.front().method().finalReturnType();
181  } else {
183  storageNeedsDestructor_ = false;
184  }
185  retType_ = reco::typeCode(typeStack[1]); // typeStack[0] = type of self, typeStack[1] = type of ret
186 }
type
Definition: HCALResponse.h:21
method::TypeCode retType_
Definition: MethodInvoker.h:63
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:68
static bool makeStorage(edm::ObjectWithDict &obj, const edm::TypeWithDict &retType)
std::vector< edm::TypeWithDict > TypeStack
Definition: TypeStack.h:17
std::vector< AnyMethodArgument > MethodArgumentStack
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:65
TypeCode typeCode(const edm::TypeWithDict &t)
Definition: returnType.cc:38
std::vector< LazyInvoker > LazyMethodStack
Definition: MethodStack.h:18
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:64
SingleInvoker::~SingleInvoker ( )

Definition at line 188 of file MethodInvoker.cc.

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

189 {
191 }
static void delStorage(edm::ObjectWithDict &obj)
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:65

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 194 of file MethodInvoker.cc.

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

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

195 {
196  /* std::cerr << "[SingleInvoker::invoke] member " << invokers_.front().method().qualifiedName() <<
197  " of type " << o.typeOf().qualifiedName() <<
198  (!isRefGet_ ? " is one shot" : " needs another round") << std::endl; */
199  pair<edm::ObjectWithDict,bool> ret(invokers_.front().invoke(o, storage_), !isRefGet_);
201  //std::cout << "Storage type: " << storage_.typeOf().qualifiedName() << ", I have to call the destructor." << std::endl;
202  v.push_back(storage_);
203  }
204  return ret;
205 }
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:68
edm::ObjectWithDict storage_
Definition: MethodInvoker.h:65
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:64
double SingleInvoker::retToDouble ( const edm::ObjectWithDict o) const

Definition at line 208 of file MethodInvoker.cc.

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

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

208  {
211  }
213 }
method::TypeCode retType_
Definition: MethodInvoker.h:63
static bool isValidReturnType(method::TypeCode)
static double objToDouble(const edm::ObjectWithDict &obj, method::TypeCode type)
void throwFailedConversion(const edm::ObjectWithDict &o) const
void SingleInvoker::throwFailedConversion ( const edm::ObjectWithDict o) const

Definition at line 216 of file MethodInvoker.cc.

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

Referenced by retToDouble().

216  {
218  << "member \"" << invokers_.back().methodName()
219  << "\" return type is \"" << invokers_.back().returnTypeName()
220  << "\" retured a \"" << o.typeOf().qualifiedName()
221  << "\" which is not convertible to double.";
222 }
std::string qualifiedName() const
TypeWithDict const & typeOf() const
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:64

Member Data Documentation

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

Definition at line 64 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 68 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().

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

Definition at line 63 of file MethodInvoker.h.

Referenced by retToDouble(), and SingleInvoker().

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

Definition at line 65 of file MethodInvoker.h.

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

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

Definition at line 66 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().