![]() |
![]() |
#include <MethodInvoker.h>
Public Member Functions | |
edm::ObjectWithDict | invoke (const edm::ObjectWithDict &o, edm::ObjectWithDict &retstore) const |
bool | isFunction () const |
edm::MemberWithDict const | member () const |
edm::FunctionWithDict const | method () const |
MethodInvoker (const edm::MemberWithDict &member) | |
MethodInvoker (const edm::FunctionWithDict &method, const std::vector< AnyMethodArgument > &ints=std::vector< AnyMethodArgument >()) | |
MethodInvoker (const MethodInvoker &) | |
std::string | methodName () const |
MethodInvoker & | operator= (const MethodInvoker &) |
std::string | returnTypeName () const |
Private Member Functions | |
void | setArgs () |
Private Attributes | |
std::vector< void * > | args_ |
std::vector< AnyMethodArgument > | ints_ |
bool | isFunction_ |
edm::MemberWithDict | member_ |
edm::FunctionWithDict | method_ |
Definition at line 16 of file MethodInvoker.h.
reco::parser::MethodInvoker::MethodInvoker | ( | const edm::FunctionWithDict & | method, |
const std::vector< AnyMethodArgument > & | ints = std::vector< AnyMethodArgument >() |
||
) | [explicit] |
MethodInvoker::MethodInvoker | ( | const edm::MemberWithDict & | member | ) | [explicit] |
Definition at line 23 of file MethodInvoker.cc.
References setArgs().
: method_(), member_(member), ints_(), isFunction_(false) { setArgs(); /*std::cout << "Booking " << methodName() << " from " << member_.declaringType().name() << " with " << args_.size() << " arguments" << " (were " << ints.size() << ")" << std::endl;*/ }
MethodInvoker::MethodInvoker | ( | const MethodInvoker & | other | ) |
Definition at line 34 of file MethodInvoker.cc.
References setArgs().
: method_(other.method_), member_(other.member_), ints_(other.ints_), isFunction_(other.isFunction_) { setArgs(); }
edm::ObjectWithDict MethodInvoker::invoke | ( | const edm::ObjectWithDict & | o, |
edm::ObjectWithDict & | retstore | ||
) | const |
Invokes the method, putting the result in retval. Returns the Object that points to the result value, after removing any "*" and "&" Caller code is responsible for allocating retstore before calling 'invoke', and of deallocating it afterwards
Definition at line 71 of file MethodInvoker.cc.
References edm::ObjectWithDict::address(), args_, edm::errors::Configuration, Exception, edm::MemberWithDict::get(), edm::errors::InvalidReference, edm::FunctionWithDict::invoke(), isFunction_, edm::TypeWithDict::isPointer(), edm::TypeWithDict::isReference(), edm::TypeWithDict::isTypedef(), member_, method_, methodName(), edm::NoMod, edm::Qualified, run_regression::ret, edm::FunctionWithDict::returnType(), edm::TypeWithDict::toType(), edm::ObjectWithDict::typeOf(), and edm::MemberWithDict::typeOf().
{ edm::ObjectWithDict ret = retstore; edm::TypeWithDict retType; if(isFunction_) { /*std::cout << "Invoking " << methodName() << " from " << method_.declaringType().name(edm::TypeNameHandling::Qualified) << " on an instance of " << o.dynamicType().name(edm::TypeNameHandling::Qualified) << " at " << o.address() << " with " << args_.size() << " arguments" << std::endl; */ method_.invoke(o, &ret, args_); retType = method_.returnType(); // this is correct, it takes pointers and refs into account } else { /*std::cout << "Invoking " << methodName() << " from " << member_.declaringType().name(edm::TypeNameHandling::Qualified) << " on an instance of " << o.dynamicType().name(edm::TypeNameHandling::Qualified) << " at " << o.address() << " with " << args_.size() << " arguments" << std::endl; */ ret = member_.get(o); retType = member_.typeOf(); } void * addr = ret.address(); //std::cout << "Stored result of " << methodName() << " (type " << returnTypeName() << ") at " << addr << std::endl; if(addr==0) { throw edm::Exception(edm::errors::InvalidReference) << "method \"" << methodName() << "\" called with " << args_.size() << " arguments returned a null pointer "; } //std::cout << "Return type is " << retType.name(edm::TypeNameHandling::Qualified) << std::endl; if(retType.isPointer() || retType.isReference()) { // both need (void **)->(void *) conversion if (retType.isPointer()) { retType = retType.toType(); // for Pointers, I get the real type this way } else { retType = edm::TypeWithDict(retType, edm::TypeModifiers::NoMod); // strip cv & ref flags } while (retType.isTypedef()) retType = retType.toType(); ret = edm::ObjectWithDict(retType, *static_cast<void **>(addr)); //std::cout << "Now type is " << retType.name(edm::TypeNameHandling::Qualified) << std::endl; } if(!ret) { throw edm::Exception(edm::errors::Configuration) << "method \"" << methodName() << "\" returned void invoked on object of type \"" << o.typeOf().name(edm::TypeNameHandling::Qualified) << "\"\n"; } return ret; }
bool reco::parser::MethodInvoker::isFunction | ( | ) | const [inline] |
edm::MemberWithDict const reco::parser::MethodInvoker::member | ( | ) | const [inline] |
edm::FunctionWithDict const reco::parser::MethodInvoker::method | ( | ) | const [inline] |
std::string MethodInvoker::methodName | ( | ) | const |
Definition at line 55 of file MethodInvoker.cc.
References isFunction_, member_, method_, edm::FunctionWithDict::name(), and edm::MemberWithDict::name().
Referenced by invoke().
{ if(isFunction_) { return method_.name(); } return member_.name(); }
MethodInvoker & MethodInvoker::operator= | ( | const MethodInvoker & | other | ) |
Definition at line 39 of file MethodInvoker.cc.
References ints_, isFunction_, member_, method_, and setArgs().
{ method_ = other.method_; member_ = other.member_; ints_ = other.ints_; isFunction_ = other.isFunction_; setArgs(); return *this; }
std::string MethodInvoker::returnTypeName | ( | ) | const |
Definition at line 63 of file MethodInvoker.cc.
References isFunction_, member_, method_, edm::Qualified, edm::MemberWithDict::typeOf(), and edm::FunctionWithDict::typeOf().
{ if(isFunction_) { return method_.typeOf().name(edm::TypeNameHandling::Qualified); } return member_.typeOf().name(edm::TypeNameHandling::Qualified); }
void MethodInvoker::setArgs | ( | ) | [private] |
Definition at line 48 of file MethodInvoker.cc.
References args_, i, and ints_.
Referenced by MethodInvoker(), and operator=().
std::vector<void*> reco::parser::MethodInvoker::args_ [private] |
Definition at line 37 of file MethodInvoker.h.
std::vector<AnyMethodArgument> reco::parser::MethodInvoker::ints_ [private] |
Definition at line 36 of file MethodInvoker.h.
Referenced by operator=(), and setArgs().
bool reco::parser::MethodInvoker::isFunction_ [private] |
Definition at line 38 of file MethodInvoker.h.
Referenced by invoke(), isFunction(), methodName(), operator=(), and returnTypeName().
Definition at line 35 of file MethodInvoker.h.
Referenced by invoke(), member(), methodName(), operator=(), and returnTypeName().
Definition at line 34 of file MethodInvoker.h.
Referenced by invoke(), method(), methodName(), operator=(), and returnTypeName().