test
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 // make sure PDFSET is pulled in when linking against the
12 // archive lhapdf library.
13 extern "C" void pdfset_(void);
14 __attribute__((visibility("hidden"))) void dummy()
15 {
16  pdfset_();
17 }
18 // implementation for the Fortran callbacks from Pythia6/Herwig6
19 
21 { FortranInstance::getInstance<FortranInstance>()->upInit(); }
22 
24 { FortranInstance::getInstance<FortranInstance>()->upEvnt(); }
25 
26 void gen::upveto_(int *veto)
27 { *veto = FortranInstance::getInstance<FortranInstance>()->upVeto(); }
28 
29 // static FortranInstance members;
30 
32 
33 const std::string gen::FortranInstance::kFortranInstance = "FortranInstance";
34 
35 // FortranInstance methods
36 
38 {
39  if (currentInstance == this) {
40  edm::LogWarning("ReentrancyProblem")
41  << edm::friendlyname::friendlyName(typeid(*this).name())
42  << " destroyed while it was the "
43  "current active instance." << std::endl;
44  currentInstance = 0;
45  }
46 }
47 
48 // FortranInstance current instance tracking
49 
51 {
52  // we should add a boost::mutex here if we care about being
53  // multithread-safe
54  if (currentInstance && currentInstance != this)
56  << edm::friendlyname::friendlyName(typeid(*this).name())
57  << "::enter() called from a different "
58  "instance while an instance was already active."
59  << std::endl;
60 
61  if (!currentInstance && instanceNesting != 0)
63  << edm::friendlyname::friendlyName(typeid(*this).name())
64  << "::enter() called on an empty "
65  "instance, but instance counter is nonzero."
66  << std::endl;
67 
68  currentInstance = this;
69  instanceNesting++;
70 }
71 
73 {
74  if (!currentInstance)
76  << edm::friendlyname::friendlyName(typeid(*this).name())
77  << "::leave() called without an "
78  "active instance." << std::endl;
79  else if (currentInstance != this)
81  << edm::friendlyname::friendlyName(typeid(*this).name())
82  << "::leave() called from a "
83  "different instance." << std::endl;
84  else if (instanceNesting <= 0)
86  << edm::friendlyname::friendlyName(typeid(*this).name())
87  << "::leave() called with a "
88  "nesting level of zero." << std::endl;
89 
90  if (--instanceNesting == 0)
91  currentInstance = 0;
92 }
93 
95 {
97  << "FortranInstance::getInstance() called from "
98  "a Fortran context, but no current instance "
99  "has been registered." << std::endl;
100 }
101 
102 // Herwig callback stubs
103 
105 {
106  throw cms::Exception("UnimplementedCallback")
107  << edm::friendlyname::friendlyName(typeid(*this).name())
108  << "::upInit() stub called. "
109  "If user process needs to be generated, please derive "
110  "and implement the upInit() method." << std::endl;
111 }
112 
114 {
115  throw cms::Exception("UnimplementedCallback")
116  << edm::friendlyname::friendlyName(typeid(*this).name())
117  << "::upEvnt() stub called. "
118  "If user process needs to be generated, please derive "
119  "and implement the upEvnt() method." << std::endl;
120 }
121 
123 {
124  return false;
125 }
static void throwMissingInstance()
void upinit_()
void upevnt_()
std::string friendlyName(std::string const &iFullName)
virtual void enter()
static FortranInstance * currentInstance
static const std::string kFortranInstance
float __attribute__((vector_size(8))) float32x2_t
Definition: ExtVec.h:12
virtual void leave()
void upveto_(int *)
void pdfset_(void)