CMS 3D CMS Logo

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() { pdfset_(); }
15 // implementation for the Fortran callbacks from Pythia6/Herwig6
16 
17 void gen::upinit_() { FortranInstance::getInstance<FortranInstance>()->upInit(); }
18 
19 void gen::upevnt_() { FortranInstance::getInstance<FortranInstance>()->upEvnt(); }
20 
21 void gen::upveto_(int *veto) { *veto = FortranInstance::getInstance<FortranInstance>()->upVeto(); }
22 
23 // static FortranInstance members;
24 
26 
27 const std::string gen::FortranInstance::kFortranInstance = "FortranInstance";
28 
29 // FortranInstance methods
30 
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 }
40 
41 // FortranInstance current instance tracking
42 
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;
59  instanceNesting++;
60 }
61 
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 }
82 
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 }
89 
90 // Herwig callback stubs
91 
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 }
99 
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 }
107 
108 bool gen::FortranInstance::upVeto() { return false; }
FriendlyName.h
gen::FortranInstance
Definition: FortranInstance.h:15
MessageLogger.h
gen::FortranInstance::enter
virtual void enter()
Definition: FortranInstance.cc:43
funct::false
false
Definition: Factorize.h:29
edm::errors::LogicError
Definition: EDMException.h:37
__attribute__
__attribute__((visibility("hidden"))) void dummy()
Definition: FortranInstance.cc:14
gen::FortranInstance::kFortranInstance
static const std::string kFortranInstance
Definition: FortranInstance.h:88
gen::FortranInstance::leave
virtual void leave()
Definition: FortranInstance.cc:62
gen::FortranInstance::upEvnt
virtual void upEvnt()
Definition: FortranInstance.cc:100
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EDMException.h
gen::upveto_
void upveto_(int *)
Definition: FortranInstance.cc:21
FortranInstance.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
gen::upevnt_
void upevnt_()
Definition: FortranInstance.cc:19
edm::friendlyname::friendlyName
std::string friendlyName(std::string const &iFullName)
Definition: FriendlyName.cc:278
gen::FortranInstance::~FortranInstance
virtual ~FortranInstance() noexcept(false)
Definition: FortranInstance.cc:31
gen::FortranInstance::throwMissingInstance
static void throwMissingInstance()
Definition: FortranInstance.cc:83
Exception
Definition: hltDiff.cc:246
gen::FortranInstance::upInit
virtual void upInit()
Definition: FortranInstance.cc:92
Exception.h
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
dummy
Definition: DummySelector.h:38
gen::FortranInstance::upVeto
virtual bool upVeto()
Definition: FortranInstance.cc:108
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
gen::upinit_
void upinit_()
Definition: FortranInstance.cc:17
gen::FortranInstance::currentInstance
static FortranInstance * currentInstance
Definition: FortranInstance.h:107
pdfset_
void pdfset_(void)