#include <MethodInvoker.h>
Public Member Functions | |
std::pair< Reflex::Object, bool > | invoke (const Reflex::Object &o, std::vector< Reflex::Object > &v) const |
double | retToDouble (const Reflex::Object &o) const |
SingleInvoker (const Reflex::Type &t, const std::string &name, const std::vector< AnyMethodArgument > &args) | |
void | throwFailedConversion (const Reflex::Object &o) const |
~SingleInvoker () | |
Private Attributes | |
std::vector< MethodInvoker > | invokers_ |
bool | isRefGet_ |
true if this invoker just pops out a ref and returns (ref.get(), false) | |
method::TypeCode | retType_ |
Reflex::Object | storage_ |
bool | storageNeedsDestructor_ |
A bigger brother of the MethodInvoker:
Definition at line 39 of file MethodInvoker.h.
SingleInvoker::SingleInvoker | ( | const Reflex::Type & | t, |
const std::string & | name, | ||
const std::vector< AnyMethodArgument > & | args | ||
) |
Definition at line 134 of file MethodInvoker.cc.
References invokers_, isRefGet_, reco::parser::ExpressionVar::makeStorage(), reco::parser::MethodSetter::push(), retType_, storage_, storageNeedsDestructor_, and reco::typeCode().
{ TypeStack typeStack(1, type); LazyMethodStack dummy; MethodArgumentStack dummy2; MethodSetter setter(invokers_, dummy, typeStack, dummy2, false); isRefGet_ = !setter.push(name, args, "LazyInvoker dynamic resolution", false); //std::cerr << "SingleInvoker on type " << type.Name(QUALIFIED|SCOPED) << ", name " << name << (isRefGet_ ? " is just a ref.get " : " is real") << std::endl; storageNeedsDestructor_ = ExpressionVar::makeStorage(storage_, invokers_.front().method()); retType_ = reco::typeCode(typeStack[1]); // typeStack[0] = type of self, typeStack[1] = type of ret }
SingleInvoker::~SingleInvoker | ( | ) |
Definition at line 148 of file MethodInvoker.cc.
References reco::parser::ExpressionVar::delStorage(), and storage_.
pair< Object, bool > SingleInvoker::invoke | ( | const Reflex::Object & | o, |
std::vector< Reflex::Object > & | 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 Reflex::Object where the result is stored will be pushed in vector so that, if needed, its destructor can be called
Definition at line 154 of file MethodInvoker.cc.
References invokers_, isRefGet_, run_regression::ret, storage_, and storageNeedsDestructor_.
Referenced by reco::parser::LazyInvoker::invoke(), and reco::parser::LazyInvoker::invokeLast().
{ /* std::cerr << "[SingleInvoker::invoke] member " << invokers_.front().method().Name(QUALIFIED|SCOPED) << " of type " << o.TypeOf().Name(QUALIFIED|SCOPED) << (!isRefGet_ ? " is one shot" : " needs another round") << std::endl; */ pair<Object,bool> ret(invokers_.front().invoke(o, storage_), !isRefGet_); if (storageNeedsDestructor_) { //std::cout << "Storage type: " << storage_.TypeOf().Name(QUALIFIED|SCOPED) << ", I have to call the destructor." << std::endl; v.push_back(storage_); } return ret; }
double SingleInvoker::retToDouble | ( | const Reflex::Object & | o | ) | const |
Definition at line 168 of file MethodInvoker.cc.
References reco::parser::ExpressionVar::isValidReturnType(), reco::parser::ExpressionVar::objToDouble(), retType_, and throwFailedConversion().
Referenced by reco::parser::LazyInvoker::invokeLast().
{ if (!ExpressionVar::isValidReturnType(retType_)) { throwFailedConversion(o); } return ExpressionVar::objToDouble(o, retType_); }
void SingleInvoker::throwFailedConversion | ( | const Reflex::Object & | o | ) | const |
Definition at line 176 of file MethodInvoker.cc.
References edm::errors::Configuration, Exception, and invokers_.
Referenced by retToDouble().
{ throw edm::Exception(edm::errors::Configuration) << "member \"" << invokers_.back().method().Name(QUALIFIED) << "\" return type is \"" << invokers_.back().method().TypeOf().Name(QUALIFIED) << "\" retured a \"" << o.TypeOf().Name(QUALIFIED) << "\" which is not convertible to double."; }
std::vector<MethodInvoker> reco::parser::SingleInvoker::invokers_ [private] |
Definition at line 56 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 60 of file MethodInvoker.h.
Referenced by invoke(), and SingleInvoker().
Definition at line 55 of file MethodInvoker.h.
Referenced by retToDouble(), and SingleInvoker().
Reflex::Object reco::parser::SingleInvoker::storage_ [mutable, private] |
Definition at line 57 of file MethodInvoker.h.
Referenced by invoke(), SingleInvoker(), and ~SingleInvoker().
bool reco::parser::SingleInvoker::storageNeedsDestructor_ [private] |
Definition at line 58 of file MethodInvoker.h.
Referenced by invoke(), and SingleInvoker().