CMS 3D CMS Logo

ModuleCallingContext.cc
Go to the documentation of this file.
7 
8 #include <ostream>
9 
10 namespace edm {
11 
13  : previousModuleOnThread_(nullptr), moduleDescription_(moduleDescription), parent_(), state_(State::kInvalid) {}
14 
16  State state,
17  ParentContext const& parent,
18  ModuleCallingContext const* previousOnThread)
19  : previousModuleOnThread_(previousOnThread),
20  moduleDescription_(moduleDescription),
21  parent_(parent),
22  state_(state) {}
23 
25  ParentContext const& parent,
26  ModuleCallingContext const* previousOnThread) {
27  state_ = state;
28  parent_ = parent;
29  previousModuleOnThread_ = previousOnThread;
30  }
31 
35  return mcc->placeInPathContext()->pathContext()->streamContext();
36  } else if (mcc->type() != ParentContext::Type::kStream) {
38  << "ModuleCallingContext::getStreamContext() called in context not linked to a StreamContext\n";
39  }
40  return mcc->streamContext();
41  }
42 
45  if (mcc->type() != ParentContext::Type::kGlobal) {
47  << "ModuleCallingContext::getGlobalContext() called in context not linked to a GlobalContext\n";
48  }
49  return mcc->globalContext();
50  }
51 
53  ModuleCallingContext const* mcc = this;
54  while (mcc->type() == ParentContext::Type::kModule) {
55  mcc = mcc->moduleCallingContext();
56  }
57  if (mcc->type() == ParentContext::Type::kInternal) {
58  mcc = mcc->internalContext()->moduleCallingContext();
59  }
60  while (mcc->type() == ParentContext::Type::kModule) {
61  mcc = mcc->moduleCallingContext();
62  }
63  return mcc;
64  }
65 
66  unsigned ModuleCallingContext::depth() const {
67  unsigned depth = 0;
68  ModuleCallingContext const* mcc = this;
69  while (mcc->type() == ParentContext::Type::kModule) {
70  ++depth;
71  mcc = mcc->moduleCallingContext();
72  }
73  if (mcc->type() == ParentContext::Type::kInternal) {
74  ++depth;
75  mcc = mcc->internalContext()->moduleCallingContext();
76  }
77  while (mcc->type() == ParentContext::Type::kModule) {
78  ++depth;
79  mcc = mcc->moduleCallingContext();
80  }
81  return depth;
82  }
83 
84  std::ostream& operator<<(std::ostream& os, ModuleCallingContext const& mcc) {
85  os << "ModuleCallingContext state = ";
86  switch (mcc.state()) {
88  os << "Invalid";
89  break;
91  os << "Prefetching";
92  break;
94  os << "Running";
95  break;
96  }
97  os << "\n";
99  return os;
100  }
101  if (mcc.moduleDescription()) {
102  os << " moduleDescription: " << *mcc.moduleDescription() << "\n";
103  }
104  os << " " << mcc.parent();
105  if (mcc.previousModuleOnThread()) {
107  os << " previousModuleOnThread: same as parent module\n";
108  } else {
109  os << " previousModuleOnThread: " << *mcc.previousModuleOnThread();
110  }
111  }
112  return os;
113  }
114 } // namespace edm
edm::ModuleCallingContext::state
State state() const
Definition: ModuleCallingContext.h:51
edm::ModuleCallingContext::parent_
ParentContext parent_
Definition: ModuleCallingContext.h:80
ModuleCallingContext.h
edm::InternalContext::moduleCallingContext
ModuleCallingContext const * moduleCallingContext() const
Definition: InternalContext.h:28
edm::ModuleCallingContext::State::kPrefetching
edm::PathContext::streamContext
StreamContext const * streamContext() const
Definition: PathContext.h:31
edm::errors::LogicError
Definition: EDMException.h:37
edm::ModuleCallingContext::State
State
Definition: ModuleCallingContext.h:33
PlaceInPathContext.h
edm::ModuleCallingContext::placeInPathContext
PlaceInPathContext const * placeInPathContext() const
Definition: ModuleCallingContext.h:55
edm::ModuleCallingContext::globalContext
GlobalContext const * globalContext() const
Definition: ModuleCallingContext.h:57
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ModuleCallingContext::streamContext
StreamContext const * streamContext() const
Definition: ModuleCallingContext.h:56
edm::PlaceInPathContext::pathContext
PathContext const * pathContext() const
Definition: PlaceInPathContext.h:24
edm::ModuleCallingContext::type
Type type() const
Definition: ModuleCallingContext.h:52
edm::ParentContext::Type::kStream
edm::ParentContext::Type::kGlobal
edm::ParentContext::Type::kPlaceInPath
edm::ModuleCallingContext::State::kInvalid
edm::ModuleCallingContext::moduleDescription
ModuleDescription const * moduleDescription() const
Definition: ModuleCallingContext.h:50
edm::ModuleCallingContext::parent
ParentContext const & parent() const
Definition: ModuleCallingContext.h:53
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::ModuleCallingContext::moduleCallingContext
ModuleCallingContext const * moduleCallingContext() const
Definition: ModuleCallingContext.h:54
ModuleDescription.h
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
EDMException.h
edm::StreamContext
Definition: StreamContext.h:31
edm::ModuleCallingContext::internalContext
InternalContext const * internalContext() const
Definition: ModuleCallingContext.h:58
edm::ParentContext::Type::kInternal
edm::ModuleCallingContext::depth
unsigned depth() const
Definition: ModuleCallingContext.cc:66
edm::ParentContext::Type::kModule
edm::ParentContext
Definition: ParentContext.h:27
edm::ModuleCallingContext::previousModuleOnThread_
ModuleCallingContext const * previousModuleOnThread_
Definition: ModuleCallingContext.h:78
edm::GlobalContext
Definition: GlobalContext.h:29
edm::ModuleCallingContext::previousModuleOnThread
ModuleCallingContext const * previousModuleOnThread() const
Definition: ModuleCallingContext.h:75
edm::ModuleCallingContext::getStreamContext
StreamContext const * getStreamContext() const
Definition: ModuleCallingContext.cc:32
edm::ModuleCallingContext::setContext
void setContext(State state, ParentContext const &parent, ModuleCallingContext const *previousOnThread)
Definition: ModuleCallingContext.cc:24
InternalContext.h
edm::ModuleCallingContext::getGlobalContext
GlobalContext const * getGlobalContext() const
Definition: ModuleCallingContext.cc:43
PathContext.h
edm::ModuleCallingContext::getTopModuleCallingContext
ModuleCallingContext const * getTopModuleCallingContext() const
Definition: ModuleCallingContext.cc:52
edm::ModuleCallingContext::state_
State state_
Definition: ModuleCallingContext.h:81
Exception
Definition: hltDiff.cc:246
edm::ModuleCallingContext::ModuleCallingContext
ModuleCallingContext(ModuleDescription const *moduleDescription)
Definition: ModuleCallingContext.cc:12
class-composition.parent
parent
Definition: class-composition.py:88
edm::ModuleCallingContext::State::kRunning
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29