CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | 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 myPythia6ServiceWithCallback

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 ()
 

Static Public Member Functions

template<typename T >
static TgetInstance ()
 

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 13 of file FortranInstance.h.

Constructor & Destructor Documentation

gen::FortranInstance::FortranInstance ( )
inline

Definition at line 15 of file FortranInstance.h.

gen::FortranInstance::~FortranInstance ( )
virtual

Definition at line 36 of file FortranInstance.cc.

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

37 {
38  if (currentInstance == this) {
39  edm::LogWarning("ReentrancyProblem")
40  << edm::friendlyname::friendlyName(typeid(*this).name())
41  << " destroyed while it was the "
42  "current active instance." << std::endl;
43  currentInstance = 0;
44  }
45 }
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 20 of file FortranInstance.h.

References wrapper.

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

Definition at line 22 of file FortranInstance.h.

References wrapper.

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

Definition at line 24 of file FortranInstance.h.

References wrapper.

25  { InstanceWrapper wrapper(this); return fn(a); }
double a
Definition: hdecay.h:121
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 26 of file FortranInstance.h.

References wrapper.

27  { InstanceWrapper wrapper(this); fn(a1, a2); }
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 28 of file FortranInstance.h.

References wrapper.

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

Reimplemented in gen::Pythia6Service.

Definition at line 49 of file FortranInstance.cc.

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

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

50 {
51  // we should add a boost::mutex here if we care about being
52  // multithread-safe
53  if (currentInstance && currentInstance != this)
55  << edm::friendlyname::friendlyName(typeid(*this).name())
56  << "::enter() called from a different "
57  "instance while an instance was already active."
58  << std::endl;
59 
60  if (!currentInstance && instanceNesting != 0)
62  << edm::friendlyname::friendlyName(typeid(*this).name())
63  << "::enter() called on an empty "
64  "instance, but instance counter is nonzero."
65  << std::endl;
66 
67  currentInstance = this;
69 }
std::string friendlyName(std::string const &iFullName)
static FortranInstance * currentInstance
template<typename T >
static T* gen::FortranInstance::getInstance ( )
inlinestatic

Definition at line 56 of file FortranInstance.h.

References currentInstance, instance, and throwMissingInstance().

57  {
58  T *instance = dynamic_cast<T*>(currentInstance);
59  if (!instance)
61  return instance;
62  }
static PFTauRenderPlugin instance
static void throwMissingInstance()
static FortranInstance * currentInstance
long double T
void gen::FortranInstance::leave ( )
virtual

Definition at line 71 of file FortranInstance.cc.

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

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

72 {
73  if (!currentInstance)
75  << edm::friendlyname::friendlyName(typeid(*this).name())
76  << "::leave() called without an "
77  "active instance." << std::endl;
78  else if (currentInstance != this)
80  << edm::friendlyname::friendlyName(typeid(*this).name())
81  << "::leave() called from a "
82  "different instance." << std::endl;
83  else if (instanceNesting <= 0)
85  << edm::friendlyname::friendlyName(typeid(*this).name())
86  << "::leave() called with a "
87  "nesting level of zero." << std::endl;
88 
89  if (--instanceNesting == 0)
90  currentInstance = 0;
91 }
std::string friendlyName(std::string const &iFullName)
static FortranInstance * currentInstance
void gen::FortranInstance::throwMissingInstance ( )
staticprivate

Definition at line 93 of file FortranInstance.cc.

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

Referenced by getInstance().

94 {
96  << "FortranInstance::getInstance() called from "
97  "a Fortran context, but no current instance "
98  "has been registered." << std::endl;
99 }
void gen::FortranInstance::upEvnt ( )
virtual

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

Definition at line 112 of file FortranInstance.cc.

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

113 {
114  throw cms::Exception("UnimplementedCallback")
115  << edm::friendlyname::friendlyName(typeid(*this).name())
116  << "::upEvnt() stub called. "
117  "If user process needs to be generated, please derive "
118  "and implement the upEvnt() method." << std::endl;
119 }
std::string friendlyName(std::string const &iFullName)
void gen::FortranInstance::upInit ( )
virtual

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

Definition at line 103 of file FortranInstance.cc.

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

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

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

Definition at line 121 of file FortranInstance.cc.

122 {
123  return false;
124 }

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 86 of file FortranInstance.h.

Referenced by getInstance(), and ~FortranInstance().

int gen::FortranInstance::instanceNesting
private

Definition at line 83 of file FortranInstance.h.