CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FortranInstance.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <typeinfo>
3 
8 
10 
11 // implementation for the Fortran callbacks from Pythia6/Herwig6
12 
14 { FortranInstance::getInstance<FortranInstance>()->upInit(); }
15 
17 { FortranInstance::getInstance<FortranInstance>()->upEvnt(); }
18 
19 void gen::upveto_(int *veto)
20 { *veto = FortranInstance::getInstance<FortranInstance>()->upVeto(); }
21 
22 // static FortranInstance members;
23 
25 
26 // FortranInstance methods
27 
29 {
30  if (currentInstance == this) {
31  edm::LogWarning("ReentrancyProblem")
32  << edm::friendlyname::friendlyName(typeid(*this).name())
33  << " destroyed while it was the "
34  "current active instance." << std::endl;
35  currentInstance = 0;
36  }
37 }
38 
39 // FortranInstance current instance tracking
40 
42 {
43  // we should add a boost::mutex here if we care about being
44  // multithread-safe
45  if (currentInstance && currentInstance != this)
47  << edm::friendlyname::friendlyName(typeid(*this).name())
48  << "::enter() called from a different "
49  "instance while an instance was already active."
50  << std::endl;
51 
52  if (!currentInstance && instanceNesting != 0)
54  << edm::friendlyname::friendlyName(typeid(*this).name())
55  << "::enter() called on an empty "
56  "instance, but instance counter is nonzero."
57  << std::endl;
58 
59  currentInstance = this;
60  instanceNesting++;
61 }
62 
64 {
65  if (!currentInstance)
67  << edm::friendlyname::friendlyName(typeid(*this).name())
68  << "::leave() called without an "
69  "active instance." << std::endl;
70  else if (currentInstance != this)
72  << edm::friendlyname::friendlyName(typeid(*this).name())
73  << "::leave() called from a "
74  "different instance." << std::endl;
75  else if (instanceNesting <= 0)
77  << edm::friendlyname::friendlyName(typeid(*this).name())
78  << "::leave() called with a "
79  "nesting level of zero." << std::endl;
80 
81  if (--instanceNesting == 0)
82  currentInstance = 0;
83 }
84 
86 {
88  << "FortranInstance::getInstance() called from "
89  "a Fortran context, but no current instance "
90  "has been registered." << std::endl;
91 }
92 
93 // Herwig callback stubs
94 
96 {
97  throw cms::Exception("UnimplementedCallback")
98  << edm::friendlyname::friendlyName(typeid(*this).name())
99  << "::upInit() stub called. "
100  "If user process needs to be generated, please derive "
101  "and implement the upInit() method." << std::endl;
102 }
103 
105 {
106  throw cms::Exception("UnimplementedCallback")
107  << edm::friendlyname::friendlyName(typeid(*this).name())
108  << "::upEvnt() stub called. "
109  "If user process needs to be generated, please derive "
110  "and implement the upEvnt() method." << std::endl;
111 }
112 
114 {
115  return false;
116 }
static void throwMissingInstance()
void upinit_()
void upevnt_()
virtual void upInit()
std::string friendlyName(std::string const &iFullName)
virtual void enter()
static FortranInstance * currentInstance
virtual void leave()
void upveto_(int *)