CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
GlobalContext const * globalContext() const
StreamContext const * getStreamContext() const
ModuleCallingContext const * moduleCallingContext() const
ModuleCallingContext const * getTopModuleCallingContext() const
ModuleDescription const * moduleDescription_
InternalContext const * internalContext() const
#define nullptr
ModuleCallingContext const * moduleCallingContext() const
void setContext(State state, ParentContext const &parent, ModuleCallingContext const *previousOnThread)
ParentContext const & parent() const
PathContext const * pathContext() const
ModuleDescription const * moduleDescription() const
StreamContext const * streamContext() const
StreamContext const * streamContext() const
Definition: PathContext.h:31
ModuleCallingContext const * previousModuleOnThread() const
HLT enums.
ModuleCallingContext(ModuleDescription const *moduleDescription)
GlobalContext const * getGlobalContext() const
ModuleCallingContext const * previousModuleOnThread_
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
PlaceInPathContext const * placeInPathContext() const