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 Member Functions | Private Attributes
reco::parser::MethodInvoker Struct Reference

#include <MethodInvoker.h>

Public Member Functions

Reflex::Object invoke (const Reflex::Object &o, Reflex::Object &retstore) const
 
const Reflex::Member & method () const
 
 MethodInvoker (const Reflex::Member &method, const std::vector< AnyMethodArgument > &ints=std::vector< AnyMethodArgument >())
 
 MethodInvoker (const MethodInvoker &)
 
MethodInvokeroperator= (const MethodInvoker &)
 

Private Member Functions

void setArgs ()
 

Private Attributes

std::vector< void * > args_
 
std::vector< AnyMethodArgumentints_
 
bool isFunction_
 
Reflex::Member method_
 

Detailed Description

Definition at line 15 of file MethodInvoker.h.

Constructor & Destructor Documentation

reco::parser::MethodInvoker::MethodInvoker ( const Reflex::Member &  method,
const std::vector< AnyMethodArgument > &  ints = std::vector< AnyMethodArgument >() 
)
explicit
MethodInvoker::MethodInvoker ( const MethodInvoker other)

Definition at line 24 of file MethodInvoker.cc.

References setArgs().

24  :
25  method_(other.method_), ints_(other.ints_), isFunction_(other.isFunction_) {
26  setArgs();
27 }
std::vector< AnyMethodArgument > ints_
Definition: MethodInvoker.h:29

Member Function Documentation

Reflex::Object MethodInvoker::invoke ( const Reflex::Object &  o,
Reflex::Object &  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 44 of file MethodInvoker.cc.

References args_, edm::errors::Configuration, edm::hlt::Exception, edm::errors::InvalidReference, isFunction_, method_, and run_regression::ret.

44  {
45  Reflex::Object ret = retstore;
46  /*std::cout << "Invoking " << method_.Name()
47  << " from " << method_.DeclaringType().Name(QUALIFIED)
48  << " on an instance of " << o.DynamicType().Name(QUALIFIED)
49  << " at " << o.Address()
50  << " with " << args_.size() << " arguments"
51  << std::endl; */
52  Type retType;
53  if(isFunction_) {
54  method_.Invoke(o, &ret, args_);
55  retType = method_.TypeOf().ReturnType(); // this is correct, it takes pointers and refs into account
56  } else {
57  ret = method_.Get(o);
58  retType = method_.TypeOf();
59  }
60  void * addr = ret.Address();
61  //std::cout << "Stored result of " << method_.Name() << " (type " << method_.TypeOf().ReturnType().Name(QUALIFIED) << ") at " << addr << std::endl;
62  if(addr==0)
64  << "method \"" << method_.Name() << "\" called with " << args_.size()
65  << " arguments returned a null pointer ";
66  //std::cout << "Return type is " << retType.Name(QUALIFIED) << std::endl;
67 
68  if(retType.IsPointer() || retType.IsReference()) { // both need (void **)->(void *) conversion
69  if (retType.IsPointer()) {
70  retType = retType.ToType(); // for Pointers, I get the real type this way
71  } else {
72  retType = Type(retType, 0); // strip cv & ref flags
73  }
74  while (retType.IsTypedef()) retType = retType.ToType();
75  ret = Object(retType, *static_cast<void **>(addr));
76  //std::cout << "Now type is " << retType.Name(QUALIFIED) << std::endl;
77  }
78  if(!ret)
80  << "method \"" << method_.Name()
81  << "\" returned void invoked on object of type \""
82  << o.TypeOf().Name(QUALIFIED) << "\"\n";
83  return ret;
84 }
std::vector< void * > args_
Definition: MethodInvoker.h:30
const Reflex::Member& reco::parser::MethodInvoker::method ( ) const
inline

Definition at line 25 of file MethodInvoker.h.

References method_.

25 { return method_; }
MethodInvoker & MethodInvoker::operator= ( const MethodInvoker other)

Definition at line 29 of file MethodInvoker.cc.

References ints_, isFunction_, method_, and setArgs().

29  {
30  method_ = other.method_;
31  ints_ = other.ints_;
32  isFunction_ = other.isFunction_;
33  setArgs();
34  return *this;
35 }
std::vector< AnyMethodArgument > ints_
Definition: MethodInvoker.h:29
void MethodInvoker::setArgs ( )
private

Definition at line 37 of file MethodInvoker.cc.

References args_, i, and ints_.

Referenced by MethodInvoker(), and operator=().

37  {
38  for(size_t i = 0; i < ints_.size(); ++i) {
39  args_.push_back( boost::apply_visitor( AnyMethodArgument2VoidPtr(), ints_[i] ) );
40  }
41 }
int i
Definition: DBlmapReader.cc:9
std::vector< void * > args_
Definition: MethodInvoker.h:30
std::vector< AnyMethodArgument > ints_
Definition: MethodInvoker.h:29

Member Data Documentation

std::vector<void*> reco::parser::MethodInvoker::args_
private

Definition at line 30 of file MethodInvoker.h.

Referenced by invoke(), valtools.webpage::parseArgs(), and setArgs().

std::vector<AnyMethodArgument> reco::parser::MethodInvoker::ints_
private

Definition at line 29 of file MethodInvoker.h.

Referenced by operator=(), and setArgs().

bool reco::parser::MethodInvoker::isFunction_
private

Definition at line 31 of file MethodInvoker.h.

Referenced by invoke(), and operator=().

Reflex::Member reco::parser::MethodInvoker::method_
private

Definition at line 28 of file MethodInvoker.h.

Referenced by invoke(), method(), and operator=().