CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
reco::parser::SingleInvoker Struct Reference

#include <MethodInvoker.h>

Public Member Functions

std::pair< edm::ObjectWithDict, bool > invoke (const edm::ObjectWithDict &o, std::vector< StorageManager > &v) const
 
SingleInvokeroperator= (const SingleInvoker &)=delete
 
double retToDouble (const edm::ObjectWithDict &) const
 convert the output of invoke to a double, if possible More...
 
void returnStorage (edm::ObjectWithDict &&) const
 
 SingleInvoker (const SingleInvoker &)=delete
 
 SingleInvoker (const edm::TypeWithDict &, const std::string &name, const std::vector< AnyMethodArgument > &args)
 
void throwFailedConversion (const edm::ObjectWithDict &) const
 
 ~SingleInvoker ()
 

Private Member Functions

edm::ObjectWithDict borrowStorage () const
 
edm::ObjectWithDict createStorage (bool &needsDestructor) const
 

Private Attributes

std::vector< MethodInvokerinvokers_
 
bool isRefGet_
 true if this invoker just pops out a ref and returns (ref.get(), false) More...
 
method::TypeCode retType_
 
oneapi::tbb::concurrent_queue< edm::ObjectWithDictstorage_
 
bool storageNeedsDestructor_
 

Detailed Description

A bigger brother of the MethodInvoker:

Definition at line 88 of file MethodInvoker.h.

Constructor & Destructor Documentation

◆ SingleInvoker() [1/2]

reco::parser::SingleInvoker::SingleInvoker ( const SingleInvoker )
delete

◆ SingleInvoker() [2/2]

SingleInvoker::SingleInvoker ( const edm::TypeWithDict type,
const std::string &  name,
const std::vector< AnyMethodArgument > &  args 
)

Definition at line 189 of file MethodInvoker.cc.

References writedatasetfile::args, createStorage(), invokers_, isRefGet_, Skims_PA_cff::name, reco::parser::MethodSetter::push(), retType_, returnStorage(), storageNeedsDestructor_, and reco::typeCode().

191  {
192  TypeStack typeStack(1, type);
194  MethodArgumentStack dummy2;
195  MethodSetter setter(invokers_, dummy, typeStack, dummy2, false);
196  isRefGet_ = !setter.push(name, args, "LazyInvoker dynamic resolution", false);
197  //std::cerr << "SingleInvoker on type " << type.qualifiedName() <<
198  // ", name " << name << (isRefGet_ ? " is just a ref.get " : " is real") <<
199  // std::endl;
201  // typeStack[0] = type of self
202  // typeStack[1] = type of ret
203  retType_ = reco::typeCode(typeStack[1]);
204 }
method::TypeCode retType_
Definition: MethodInvoker.h:90
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:95
std::vector< edm::TypeWithDict > TypeStack
Definition: TypeStack.h:17
edm::ObjectWithDict createStorage(bool &needsDestructor) const
void returnStorage(edm::ObjectWithDict &&) const
std::vector< AnyMethodArgument > MethodArgumentStack
method::TypeCode typeCode(const edm::TypeWithDict &)
Definition: returnType.cc:39
std::vector< LazyInvoker > LazyMethodStack
Definition: MethodStack.h:18
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:91

◆ ~SingleInvoker()

SingleInvoker::~SingleInvoker ( )

Definition at line 206 of file MethodInvoker.cc.

References reco::parser::ExpressionVar::delStorage(), and storage_.

206  {
207  edm::ObjectWithDict stored;
208  while (storage_.try_pop(stored)) {
209  //std::cout <<"deleting "<<stored.address()<<" from "<<this<<std::endl;
211  }
212 }
oneapi::tbb::concurrent_queue< edm::ObjectWithDict > storage_
Definition: MethodInvoker.h:92
static void delStorage(edm::ObjectWithDict &)

Member Function Documentation

◆ borrowStorage()

edm::ObjectWithDict SingleInvoker::borrowStorage ( ) const
private

Definition at line 225 of file MethodInvoker.cc.

References createStorage(), EcalTangentSkim_cfg::o, and storage_.

Referenced by invoke().

225  {
227  if (storage_.try_pop(o)) {
228  //std::cout <<"borrowed "<<o.address()<<" from "<<this<<std::endl;
229  return o;
230  }
231  bool dummy;
232  o = createStorage(dummy);
233  //std::cout <<"borrowed new "<<o.address()<<std::endl;
234  return o;
235 }
edm::ObjectWithDict createStorage(bool &needsDestructor) const
oneapi::tbb::concurrent_queue< edm::ObjectWithDict > storage_
Definition: MethodInvoker.h:92

◆ createStorage()

edm::ObjectWithDict SingleInvoker::createStorage ( bool &  needsDestructor) const
private

Definition at line 214 of file MethodInvoker.cc.

References invokers_, and reco::parser::ExpressionVar::makeStorage().

Referenced by borrowStorage(), and SingleInvoker().

214  {
215  if (invokers_.front().isFunction()) {
216  edm::TypeWithDict retType = invokers_.front().method().finalReturnType();
217  edm::ObjectWithDict stored;
218  needsDestructor = ExpressionVar::makeStorage(stored, retType);
219  return stored;
220  }
221  needsDestructor = false;
222  return edm::ObjectWithDict();
223 }
static bool makeStorage(edm::ObjectWithDict &obj, const edm::TypeWithDict &retType)
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:91

◆ invoke()

pair< edm::ObjectWithDict, bool > SingleInvoker::invoke ( const edm::ObjectWithDict o,
std::vector< StorageManager > &  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 edm::ObjectWithDict where the result is stored will be pushed in vector so that, if needed, its destructor can be called

Definition at line 242 of file MethodInvoker.cc.

References borrowStorage(), invokers_, isRefGet_, EcalTangentSkim_cfg::o, runTheMatrix::ret, storageNeedsDestructor_, and findQualityFiles::v.

Referenced by reco::parser::LazyInvoker::invoke().

243  {
244  // std::cerr << "[SingleInvoker::invoke] member " <<
245  // invokers_.front().method().qualifiedName() <<
246  // " of type " <<
247  // o.typeOf().qualifiedName() <<
248  // (!isRefGet_ ? " is one shot" : " needs another round") <<
249  // std::endl;
250  auto storage = borrowStorage();
251  pair<edm::ObjectWithDict, bool> ret(invokers_.front().invoke(o, storage), !isRefGet_);
252  v.emplace_back(storage, this, storageNeedsDestructor_);
253  return ret;
254 }
bool isRefGet_
true if this invoker just pops out a ref and returns (ref.get(), false)
Definition: MethodInvoker.h:95
ret
prodAgent to be discontinued
edm::ObjectWithDict borrowStorage() const
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:91

◆ operator=()

SingleInvoker& reco::parser::SingleInvoker::operator= ( const SingleInvoker )
delete

◆ retToDouble()

double SingleInvoker::retToDouble ( const edm::ObjectWithDict o) const

convert the output of invoke to a double, if possible

Definition at line 256 of file MethodInvoker.cc.

References reco::parser::ExpressionVar::isValidReturnType(), EcalTangentSkim_cfg::o, reco::parser::ExpressionVar::objToDouble(), retType_, and throwFailedConversion().

256  {
259  }
261 }
method::TypeCode retType_
Definition: MethodInvoker.h:90
static double objToDouble(const edm::ObjectWithDict &obj, method::TypeCode type)
static bool isValidReturnType(method::TypeCode)
void throwFailedConversion(const edm::ObjectWithDict &) const

◆ returnStorage()

void SingleInvoker::returnStorage ( edm::ObjectWithDict &&  o) const

Definition at line 237 of file MethodInvoker.cc.

References eostools::move(), EcalTangentSkim_cfg::o, and storage_.

Referenced by SingleInvoker(), and reco::parser::StorageManager::~StorageManager().

237  {
238  //std::cout <<"returned "<<o.address()<<" to "<<this<<std::endl;
239  storage_.push(std::move(o));
240 }
oneapi::tbb::concurrent_queue< edm::ObjectWithDict > storage_
Definition: MethodInvoker.h:92
def move(src, dest)
Definition: eostools.py:511

◆ throwFailedConversion()

void SingleInvoker::throwFailedConversion ( const edm::ObjectWithDict o) const

Definition at line 263 of file MethodInvoker.cc.

References edm::errors::Configuration, Exception, invokers_, and EcalTangentSkim_cfg::o.

Referenced by retToDouble().

263  {
265  << "member \"" << invokers_.back().methodName() << "\" return type is \"" << invokers_.back().returnTypeName()
266  << "\" retured a \"" << o.typeOf().qualifiedName() << "\" which is not convertible to double.";
267 }
std::vector< MethodInvoker > invokers_
Definition: MethodInvoker.h:91

Member Data Documentation

◆ invokers_

std::vector<MethodInvoker> reco::parser::SingleInvoker::invokers_
private

Definition at line 91 of file MethodInvoker.h.

Referenced by createStorage(), invoke(), SingleInvoker(), and throwFailedConversion().

◆ isRefGet_

bool reco::parser::SingleInvoker::isRefGet_
private

true if this invoker just pops out a ref and returns (ref.get(), false)

Definition at line 95 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().

◆ retType_

method::TypeCode reco::parser::SingleInvoker::retType_
private

Definition at line 90 of file MethodInvoker.h.

Referenced by retToDouble(), and SingleInvoker().

◆ storage_

oneapi::tbb::concurrent_queue<edm::ObjectWithDict> reco::parser::SingleInvoker::storage_
mutableprivate

Definition at line 92 of file MethodInvoker.h.

Referenced by borrowStorage(), returnStorage(), and ~SingleInvoker().

◆ storageNeedsDestructor_

bool reco::parser::SingleInvoker::storageNeedsDestructor_
private

Definition at line 93 of file MethodInvoker.h.

Referenced by invoke(), and SingleInvoker().