test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 101 of file MethodInvoker.h.

Member Typedef Documentation

Definition at line 103 of file MethodInvoker.h.

Definition at line 102 of file MethodInvoker.h.

Constructor & Destructor Documentation

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

Definition at line 177 of file MethodInvoker.cc.

179  : name_(name)
181 {
182 }
std::vector< AnyMethodArgument > argsBeforeFixups_
LazyInvoker::~LazyInvoker ( )

Definition at line 184 of file MethodInvoker.cc.

185 {
186 }

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

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

207 {
208  pair<edm::ObjectWithDict, bool> ret(o, false);
209  do {
210  edm::TypeWithDict type = ret.first.typeOf();
211  if (type.isClass()) {
212  type = ret.first.dynamicType();
213  }
214  ret = invoker(type).invoke(edm::ObjectWithDict(type, ret.first.address()), v);
215  }
216  while (ret.second == false);
217  return ret.first;
218 }
type
Definition: HCALResponse.h:21
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 222 of file MethodInvoker.cc.

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

224 {
225  pair<edm::ObjectWithDict, bool> ret(o, false);
226  const SingleInvoker* i = 0;
227  do {
228  edm::TypeWithDict type = ret.first.typeOf();
229  if (type.isClass()) {
230  type = ret.first.dynamicType();
231  }
232  i = &invoker(type);
233  ret = i->invoke(edm::ObjectWithDict(type, ret.first.address()), v);
234  }
235  while (ret.second == false);
236  return i->retToDouble(ret.first);
237 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
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 190 of file MethodInvoker.cc.

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

Referenced by invoke(), and invokeLast().

191 {
192  //std::cout << "LazyInvoker for " << name_ << " called on type " <<
193  // type.qualifiedName() << std::endl;
194  const edm::TypeID thetype(type.typeInfo());
195  auto found = invokers_.find(thetype);
196  if( found != invokers_.cend() ) {
197  return *(found->second);
198  }
199  auto to_add = std::make_shared<SingleInvoker>(type, name_, argsBeforeFixups_);
200  auto emplace_result = invokers_.insert(std::make_pair(thetype,to_add) );
201  return *(emplace_result.first->second);
202 }
type
Definition: HCALResponse.h:21
std::type_info const & typeInfo() const
std::vector< AnyMethodArgument > argsBeforeFixups_

Member Data Documentation

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

Definition at line 106 of file MethodInvoker.h.

Referenced by invoker().

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

Definition at line 110 of file MethodInvoker.h.

Referenced by invoker().

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

Definition at line 105 of file MethodInvoker.h.

Referenced by invoker().