CMS 3D CMS Logo

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

Keeps different SingleInvokers for each dynamic type of the objects passed to invoke() More...

#include <MethodInvoker.h>

Public Types

typedef
tbb::concurrent_unordered_map
< edm::TypeID,
SingleInvokerPtr,
edm::TypeIDHasher
InvokerMap
 
typedef std::shared_ptr
< SingleInvoker
SingleInvokerPtr
 

Public Member Functions

edm::ObjectWithDict invoke (const edm::ObjectWithDict &o, std::vector< edm::ObjectWithDict > &v) const
 
double invokeLast (const edm::ObjectWithDict &o, std::vector< edm::ObjectWithDict > &v) const
 invoke and coerce result to double More...
 
 LazyInvoker (const std::string &name, const std::vector< AnyMethodArgument > &args)
 
 ~LazyInvoker ()
 

Private Member Functions

const SingleInvokerinvoker (const edm::TypeWithDict &) const
 

Private Attributes

std::vector< AnyMethodArgumentargsBeforeFixups_
 
InvokerMap invokers_
 
std::string name_
 

Detailed Description

Keeps different SingleInvokers for each dynamic type of the objects passed to invoke()

Definition at line 96 of file MethodInvoker.h.

Member Typedef Documentation

Definition at line 98 of file MethodInvoker.h.

Definition at line 97 of file MethodInvoker.h.

Constructor & Destructor Documentation

LazyInvoker::LazyInvoker ( const std::string &  name,
const std::vector< AnyMethodArgument > &  args 
)
explicit

Definition at line 144 of file MethodInvoker.cc.

LazyInvoker::~LazyInvoker ( )

Definition at line 147 of file MethodInvoker.cc.

147 {}

Member Function Documentation

edm::ObjectWithDict LazyInvoker::invoke ( const edm::ObjectWithDict o,
std::vector< edm::ObjectWithDict > &  v 
) const

invoke method, returns object that points to result (after stripping '*' and '&') the object is still owned by the LazyInvoker 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 162 of file MethodInvoker.cc.

References reco::parser::SingleInvoker::invoke(), invoker(), edm::TypeWithDict::isClass(), and runTheMatrix::ret.

162  {
163  pair<edm::ObjectWithDict, bool> ret(o, false);
164  do {
165  edm::TypeWithDict type = ret.first.typeOf();
166  if (type.isClass()) {
167  type = ret.first.dynamicType();
168  }
169  ret = invoker(type).invoke(edm::ObjectWithDict(type, ret.first.address()), v);
170  } while (ret.second == false);
171  return ret.first;
172 }
tuple ret
prodAgent to be discontinued
std::pair< edm::ObjectWithDict, bool > invoke(const edm::ObjectWithDict &o, std::vector< edm::ObjectWithDict > &v) const
bool isClass() const
const SingleInvoker & invoker(const edm::TypeWithDict &) const
double LazyInvoker::invokeLast ( const edm::ObjectWithDict o,
std::vector< edm::ObjectWithDict > &  v 
) const

invoke and coerce result to double

Definition at line 174 of file MethodInvoker.cc.

References mps_fire::i, reco::parser::SingleInvoker::invoke(), invoker(), edm::TypeWithDict::isClass(), runTheMatrix::ret, and reco::parser::SingleInvoker::retToDouble().

174  {
175  pair<edm::ObjectWithDict, bool> ret(o, false);
176  const SingleInvoker* i = nullptr;
177  do {
178  edm::TypeWithDict type = ret.first.typeOf();
179  if (type.isClass()) {
180  type = ret.first.dynamicType();
181  }
182  i = &invoker(type);
183  ret = i->invoke(edm::ObjectWithDict(type, ret.first.address()), v);
184  } while (ret.second == false);
185  return i->retToDouble(ret.first);
186 }
tuple ret
prodAgent to be discontinued
std::pair< edm::ObjectWithDict, bool > invoke(const edm::ObjectWithDict &o, std::vector< edm::ObjectWithDict > &v) const
bool isClass() const
const SingleInvoker & invoker(const edm::TypeWithDict &) const
double retToDouble(const edm::ObjectWithDict &) const
convert the output of invoke to a double, if possible
const SingleInvoker & LazyInvoker::invoker ( const edm::TypeWithDict type) const
private

Definition at line 149 of file MethodInvoker.cc.

References argsBeforeFixups_, newFWLiteAna::found, invokers_, name_, and edm::TypeWithDict::typeInfo().

Referenced by invoke(), and invokeLast().

149  {
150  //std::cout << "LazyInvoker for " << name_ << " called on type " <<
151  // type.qualifiedName() << std::endl;
152  const edm::TypeID thetype(type.typeInfo());
153  auto found = invokers_.find(thetype);
154  if (found != invokers_.cend()) {
155  return *(found->second);
156  }
157  auto to_add = std::make_shared<SingleInvoker>(type, name_, argsBeforeFixups_);
158  auto emplace_result = invokers_.insert(std::make_pair(thetype, to_add));
159  return *(emplace_result.first->second);
160 }
std::type_info const & typeInfo() const
std::vector< AnyMethodArgument > argsBeforeFixups_

Member Data Documentation

std::vector<AnyMethodArgument> reco::parser::LazyInvoker::argsBeforeFixups_
private

Definition at line 102 of file MethodInvoker.h.

Referenced by invoker().

InvokerMap reco::parser::LazyInvoker::invokers_
mutableprivate

Definition at line 106 of file MethodInvoker.h.

Referenced by invoker().

std::string reco::parser::LazyInvoker::name_
private

Definition at line 101 of file MethodInvoker.h.

Referenced by invoker().