CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
gen::FortranInstance Class Reference

#include <FortranInstance.h>

Inheritance diagram for gen::FortranInstance:
gen::Herwig6Instance gen::Pythia6Service gen::PomwigHadronizer Herwig6Hadronizer MCatNLOSource gen::Pythia6ServiceWithCallback gen::Pythia6ServiceWithCallback

Classes

struct  InstanceWrapper
 

Public Member Functions

void call (void(&fn)())
 
template<typename T >
T call (T(&fn)())
 
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)
 
template<typename T , typename A1 , typename A2 >
T call (T(&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 () noexcept(false)
 

Static Public Member Functions

template<typename T >
static TgetInstance ()
 

Static Public Attributes

static const std::string kFortranInstance = "FortranInstance"
 

Static Private Member Functions

static void throwMissingInstance ()
 

Private Attributes

int instanceNesting
 

Static Private Attributes

static FortranInstancecurrentInstance = 0
 

Friends

void gen::upevnt_ ()
 
void gen::upinit_ ()
 
void gen::upveto_ (int *)
 

Detailed Description

Definition at line 15 of file FortranInstance.h.

Constructor & Destructor Documentation

gen::FortranInstance::FortranInstance ( )
inline

Definition at line 17 of file FortranInstance.h.

References noexcept, and ~FortranInstance().

gen::FortranInstance::~FortranInstance ( )
virtualnoexcept

Definition at line 31 of file FortranInstance.cc.

References currentInstance, and edm::friendlyname::friendlyName().

Referenced by FortranInstance().

31  {
32  if (currentInstance == this) {
33  edm::LogWarning("ReentrancyProblem") << edm::friendlyname::friendlyName(typeid(*this).name())
34  << " destroyed while it was the "
35  "current active instance."
36  << std::endl;
37  currentInstance = nullptr;
38  }
39 }
std::string friendlyName(std::string const &iFullName)
static FortranInstance * currentInstance

Member Function Documentation

void gen::FortranInstance::call ( void(&)()  fn)
inline
template<typename T >
T gen::FortranInstance::call ( T(&)()  fn)
inline

Definition at line 25 of file FortranInstance.h.

References personalPlayback::fn, and wrapper.

25  {
26  InstanceWrapper wrapper(this);
27  return fn();
28  }
static HepMC::HEPEVT_Wrapper wrapper
template<typename A >
void gen::FortranInstance::call ( void(&)(A)  fn,
a 
)
inline

Definition at line 30 of file FortranInstance.h.

References personalPlayback::fn, and wrapper.

30  {
31  InstanceWrapper wrapper(this);
32  fn(a);
33  }
double a
Definition: hdecay.h:119
static HepMC::HEPEVT_Wrapper wrapper
template<typename T , typename A >
T gen::FortranInstance::call ( T(&)(A)  fn,
a 
)
inline

Definition at line 35 of file FortranInstance.h.

References personalPlayback::fn, and wrapper.

35  {
36  InstanceWrapper wrapper(this);
37  return fn(a);
38  }
double a
Definition: hdecay.h:119
static HepMC::HEPEVT_Wrapper wrapper
template<typename A1 , typename A2 >
void gen::FortranInstance::call ( void(&)(A1, A2)  fn,
A1  a1,
A2  a2 
)
inline

Definition at line 40 of file FortranInstance.h.

References personalPlayback::fn, and wrapper.

40  {
41  InstanceWrapper wrapper(this);
42  fn(a1, a2);
43  }
static HepMC::HEPEVT_Wrapper wrapper
template<typename T , typename A1 , typename A2 >
T gen::FortranInstance::call ( T(&)(A1, A2)  fn,
A1  a1,
A2  a2 
)
inline

Definition at line 45 of file FortranInstance.h.

References personalPlayback::fn, and wrapper.

45  {
46  InstanceWrapper wrapper(this);
47  return fn(a1, a2);
48  }
static HepMC::HEPEVT_Wrapper wrapper
void gen::FortranInstance::enter ( )
virtual

Reimplemented in gen::Pythia6Service.

Definition at line 43 of file FortranInstance.cc.

References currentInstance, Exception, edm::friendlyname::friendlyName(), instanceNesting, and edm::errors::LogicError.

Referenced by gen::Pythia6Service::enter(), and gen::FortranInstance::InstanceWrapper::InstanceWrapper().

43  {
44  // we should add a boost::mutex here if we care about being
45  // multithread-safe
46  if (currentInstance && currentInstance != this)
48  << "::enter() called from a different "
49  "instance while an instance was already active."
50  << std::endl;
51 
52  if (!currentInstance && instanceNesting != 0)
54  << "::enter() called on an empty "
55  "instance, but instance counter is nonzero."
56  << std::endl;
57 
58  currentInstance = this;
60 }
std::string friendlyName(std::string const &iFullName)
static FortranInstance * currentInstance
template<typename T >
static T* gen::FortranInstance::getInstance ( )
inlinestatic

Definition at line 76 of file FortranInstance.h.

References currentInstance, gen::FortranInstance::InstanceWrapper::instance, throwMissingInstance(), upEvnt(), upInit(), and upVeto().

76  {
77  T *instance = dynamic_cast<T *>(currentInstance);
78  if (!instance)
80  return instance;
81  }
static PFTauRenderPlugin instance
static void throwMissingInstance()
static FortranInstance * currentInstance
long double T
void gen::FortranInstance::leave ( )
virtual

Definition at line 62 of file FortranInstance.cc.

References currentInstance, Exception, edm::friendlyname::friendlyName(), instanceNesting, and edm::errors::LogicError.

Referenced by gen::FortranInstance::InstanceWrapper::~InstanceWrapper().

62  {
63  if (!currentInstance)
65  << "::leave() called without an "
66  "active instance."
67  << std::endl;
68  else if (currentInstance != this)
70  << "::leave() called from a "
71  "different instance."
72  << std::endl;
73  else if (instanceNesting <= 0)
75  << "::leave() called with a "
76  "nesting level of zero."
77  << std::endl;
78 
79  if (--instanceNesting == 0)
80  currentInstance = nullptr;
81 }
std::string friendlyName(std::string const &iFullName)
static FortranInstance * currentInstance
void gen::FortranInstance::throwMissingInstance ( )
staticprivate

Definition at line 83 of file FortranInstance.cc.

References Exception, and edm::errors::LogicError.

Referenced by getInstance().

83  {
84  throw edm::Exception(edm::errors::LogicError) << "FortranInstance::getInstance() called from "
85  "a Fortran context, but no current instance "
86  "has been registered."
87  << std::endl;
88 }
void gen::FortranInstance::upEvnt ( )
virtual

Reimplemented in Herwig6Hadronizer, gen::Pythia6ServiceWithCallback, and gen::Pythia6ServiceWithCallback.

Definition at line 100 of file FortranInstance.cc.

References Exception, and edm::friendlyname::friendlyName().

Referenced by getInstance().

100  {
101  throw cms::Exception("UnimplementedCallback") << edm::friendlyname::friendlyName(typeid(*this).name())
102  << "::upEvnt() stub called. "
103  "If user process needs to be generated, please derive "
104  "and implement the upEvnt() method."
105  << std::endl;
106 }
std::string friendlyName(std::string const &iFullName)
void gen::FortranInstance::upInit ( )
virtual

Reimplemented in Herwig6Hadronizer, gen::Pythia6ServiceWithCallback, and gen::Pythia6ServiceWithCallback.

Definition at line 92 of file FortranInstance.cc.

References Exception, and edm::friendlyname::friendlyName().

Referenced by getInstance().

92  {
93  throw cms::Exception("UnimplementedCallback") << edm::friendlyname::friendlyName(typeid(*this).name())
94  << "::upInit() stub called. "
95  "If user process needs to be generated, please derive "
96  "and implement the upInit() method."
97  << std::endl;
98 }
std::string friendlyName(std::string const &iFullName)
bool gen::FortranInstance::upVeto ( )
virtual

Reimplemented in gen::Pythia6ServiceWithCallback, and gen::Pythia6ServiceWithCallback.

Definition at line 108 of file FortranInstance.cc.

Referenced by getInstance().

108 { return false; }

Friends And Related Function Documentation

void gen::upevnt_ ( )
friend
void gen::upinit_ ( )
friend
void gen::upveto_ ( int *  )
friend

Member Data Documentation

gen::FortranInstance * gen::FortranInstance::currentInstance = 0
staticprivate

Definition at line 107 of file FortranInstance.h.

Referenced by enter(), getInstance(), leave(), gen::upveto_(), and ~FortranInstance().

int gen::FortranInstance::instanceNesting
private

Definition at line 104 of file FortranInstance.h.

Referenced by enter(), and leave().

const std::string gen::FortranInstance::kFortranInstance = "FortranInstance"
static