#include <FortranInstance.h>
Classes | |
struct | InstanceWrapper |
Public Member Functions | |
void | call (void(&fn)()) |
template<typename T > | |
T | call (T(&fn)()) |
template<typename T , typename A1 , typename A2 > | |
T | call (T(&fn)(A1, A2), A1 a1, A2 a2) |
template<typename A > | |
void | call (void(&fn)(A), A a) |
template<typename T , typename A > | |
T | call (T(&fn)(A), A a) |
template<typename A1 , typename A2 > | |
void | call (void(&fn)(A1, A2), A1 a1, A2 a2) |
virtual void | enter () |
FortranInstance () | |
virtual void | leave () |
virtual void | upEvnt () |
virtual void | upInit () |
virtual bool | upVeto () |
virtual | ~FortranInstance () |
Static Public Member Functions | |
template<typename T > | |
static T * | getInstance () |
Static Private Member Functions | |
static void | throwMissingInstance () |
Private Attributes | |
int | instanceNesting |
Static Private Attributes | |
static FortranInstance * | currentInstance = 0 |
Friends | |
void | gen::upevnt_ () |
void | gen::upinit_ () |
void | gen::upveto_ (int *) |
Definition at line 13 of file FortranInstance.h.
gen::FortranInstance::FortranInstance | ( | ) | [inline] |
Definition at line 15 of file FortranInstance.h.
: instanceNesting(0) {}
gen::FortranInstance::~FortranInstance | ( | ) | [virtual] |
Definition at line 36 of file FortranInstance.cc.
References currentInstance, and edm::friendlyname::friendlyName().
{ if (currentInstance == this) { edm::LogWarning("ReentrancyProblem") << edm::friendlyname::friendlyName(typeid(*this).name()) << " destroyed while it was the " "current active instance." << std::endl; currentInstance = 0; } }
void gen::FortranInstance::call | ( | void(&)() | fn | ) | [inline] |
Definition at line 18 of file FortranInstance.h.
References wrapper.
Referenced by Herwig6Hadronizer::clear(), gen::PomwigHadronizer::clear(), gen::TauolaInterface::decay(), gen::Pythia6Hadronizer::imposeProperTime(), gen::TauolaInterface::init(), Herwig6Hadronizer::initialize(), gen::PomwigHadronizer::initializeForInternalPartons(), Herwig6Hadronizer::initializeForInternalPartons(), Herwig6Hadronizer::readSettings(), gen::PomwigHadronizer::readSettings(), and gen::TauolaInterface::statistics().
{ InstanceWrapper wrapper(this); fn(); }
Definition at line 20 of file FortranInstance.h.
References wrapper.
{ InstanceWrapper wrapper(this); return fn(); }
Definition at line 24 of file FortranInstance.h.
References wrapper.
void gen::FortranInstance::call | ( | void(&)(A1, A2) | fn, |
A1 | a1, | ||
A2 | a2 | ||
) | [inline] |
Definition at line 26 of file FortranInstance.h.
References wrapper.
{ InstanceWrapper wrapper(this); fn(a1, a2); }
void gen::FortranInstance::call | ( | void(&)(A) | fn, |
A | a | ||
) | [inline] |
Definition at line 22 of file FortranInstance.h.
References wrapper.
T gen::FortranInstance::call | ( | T(&)(A1, A2) | fn, |
A1 | a1, | ||
A2 | a2 | ||
) | [inline] |
Definition at line 28 of file FortranInstance.h.
References wrapper.
{ InstanceWrapper wrapper(this); return fn(a1, a2); }
void gen::FortranInstance::enter | ( | ) | [virtual] |
Reimplemented in gen::Pythia6Service.
Definition at line 49 of file FortranInstance.cc.
References Exception, edm::friendlyname::friendlyName(), and edm::errors::LogicError.
Referenced by gen::FortranInstance::InstanceWrapper::InstanceWrapper().
{ // we should add a boost::mutex here if we care about being // multithread-safe if (currentInstance && currentInstance != this) throw edm::Exception(edm::errors::LogicError) << edm::friendlyname::friendlyName(typeid(*this).name()) << "::enter() called from a different " "instance while an instance was already active." << std::endl; if (!currentInstance && instanceNesting != 0) throw edm::Exception(edm::errors::LogicError) << edm::friendlyname::friendlyName(typeid(*this).name()) << "::enter() called on an empty " "instance, but instance counter is nonzero." << std::endl; currentInstance = this; instanceNesting++; }
static T* gen::FortranInstance::getInstance | ( | ) | [inline, static] |
Definition at line 56 of file FortranInstance.h.
References currentInstance, and throwMissingInstance().
Referenced by gen::Pythia6ServiceWithCallback::upEvnt(), and gen::Pythia6ServiceWithCallback::upInit().
{ T *instance = dynamic_cast<T*>(currentInstance); if (!instance) throwMissingInstance(); return instance; }
void gen::FortranInstance::leave | ( | ) | [virtual] |
Definition at line 71 of file FortranInstance.cc.
References Exception, edm::friendlyname::friendlyName(), and edm::errors::LogicError.
Referenced by gen::FortranInstance::InstanceWrapper::~InstanceWrapper().
{ if (!currentInstance) throw edm::Exception(edm::errors::LogicError) << edm::friendlyname::friendlyName(typeid(*this).name()) << "::leave() called without an " "active instance." << std::endl; else if (currentInstance != this) throw edm::Exception(edm::errors::LogicError) << edm::friendlyname::friendlyName(typeid(*this).name()) << "::leave() called from a " "different instance." << std::endl; else if (instanceNesting <= 0) throw edm::Exception(edm::errors::LogicError) << edm::friendlyname::friendlyName(typeid(*this).name()) << "::leave() called with a " "nesting level of zero." << std::endl; if (--instanceNesting == 0) currentInstance = 0; }
void gen::FortranInstance::throwMissingInstance | ( | ) | [static, private] |
Definition at line 93 of file FortranInstance.cc.
References Exception, and edm::errors::LogicError.
Referenced by getInstance().
{ throw edm::Exception(edm::errors::LogicError) << "FortranInstance::getInstance() called from " "a Fortran context, but no current instance " "has been registered." << std::endl; }
void gen::FortranInstance::upEvnt | ( | ) | [virtual] |
Reimplemented in Herwig6Hadronizer, and gen::Pythia6ServiceWithCallback.
Definition at line 112 of file FortranInstance.cc.
References Exception, and edm::friendlyname::friendlyName().
{ throw cms::Exception("UnimplementedCallback") << edm::friendlyname::friendlyName(typeid(*this).name()) << "::upEvnt() stub called. " "If user process needs to be generated, please derive " "and implement the upEvnt() method." << std::endl; }
void gen::FortranInstance::upInit | ( | ) | [virtual] |
Reimplemented in Herwig6Hadronizer, and gen::Pythia6ServiceWithCallback.
Definition at line 103 of file FortranInstance.cc.
References Exception, and edm::friendlyname::friendlyName().
{ throw cms::Exception("UnimplementedCallback") << edm::friendlyname::friendlyName(typeid(*this).name()) << "::upInit() stub called. " "If user process needs to be generated, please derive " "and implement the upInit() method." << std::endl; }
bool gen::FortranInstance::upVeto | ( | ) | [virtual] |
Reimplemented in gen::Pythia6ServiceWithCallback.
Definition at line 121 of file FortranInstance.cc.
{ return false; }
void gen::upevnt_ | ( | ) | [friend] |
void gen::upinit_ | ( | ) | [friend] |
void gen::upveto_ | ( | int * | ) | [friend] |
gen::FortranInstance * gen::FortranInstance::currentInstance = 0 [static, private] |
Definition at line 86 of file FortranInstance.h.
Referenced by getInstance(), and ~FortranInstance().
int gen::FortranInstance::instanceNesting [private] |
Definition at line 83 of file FortranInstance.h.