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 
12 // make sure PDFSET is pulled in when linking against the
13 // archive lhapdf library.
14 extern "C" void pdfset_(void);
15 __attribute__((visibility("hidden"))) void dummy()
16 {
17  pdfset_();
18 }
19 // implementation for the Fortran callbacks from Pythia6/Herwig6
20 
22 { FortranInstance::getInstance<FortranInstance>()->upInit(); }
23 
25 { FortranInstance::getInstance<FortranInstance>()->upEvnt(); }
26 
27 void gen::upveto_(int *veto)
28 { *veto = FortranInstance::getInstance<FortranInstance>()->upVeto(); }
29 
30 // static FortranInstance members;
31 
33 
34 // FortranInstance methods
35 
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 }
46 
47 // FortranInstance current instance tracking
48 
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;
68  instanceNesting++;
69 }
70 
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 }
92 
94 {
96  << "FortranInstance::getInstance() called from "
97  "a Fortran context, but no current instance "
98  "has been registered." << std::endl;
99 }
100 
101 // Herwig callback stubs
102 
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 }
111 
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 }
120 
122 {
123  return false;
124 }
static void throwMissingInstance()
void upinit_()
void upevnt_()
std::string friendlyName(std::string const &iFullName)
virtual void enter()
static FortranInstance * currentInstance
virtual void leave()
void upveto_(int *)
void pdfset_(void)
class Geom::Polar2Cartesian __attribute__