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),
14  moduleDescription_(moduleDescription),
15  parent_(),
16  state_(State::kInvalid) {
17  }
18 
20  State state,
21  ParentContext const& parent,
22  ModuleCallingContext const* previousOnThread) :
23  previousModuleOnThread_(previousOnThread),
24  moduleDescription_(moduleDescription),
25  parent_(parent),
26  state_(state) {
27  }
28 
30  ModuleCallingContext const* previousOnThread) {
31  state_ = state;
32  parent_ = parent;
33  previousModuleOnThread_ = previousOnThread;
34  }
35 
36  StreamContext const*
40  return mcc->placeInPathContext()->pathContext()->streamContext();
41  } else if (mcc->type() != ParentContext::Type::kStream) {
43  << "ModuleCallingContext::getStreamContext() called in context not linked to a StreamContext\n";
44  }
45  return mcc->streamContext();
46  }
47 
48  GlobalContext const*
51  if (mcc->type() != ParentContext::Type::kGlobal) {
53  << "ModuleCallingContext::getGlobalContext() called in context not linked to a GlobalContext\n";
54  }
55  return mcc->globalContext();
56  }
57 
60  ModuleCallingContext const* mcc = this;
61  while(mcc->type() == ParentContext::Type::kModule) {
62  mcc = mcc->moduleCallingContext();
63  }
64  if(mcc->type() == ParentContext::Type::kInternal) {
65  mcc = mcc->internalContext()->moduleCallingContext();
66  }
67  while(mcc->type() == ParentContext::Type::kModule) {
68  mcc = mcc->moduleCallingContext();
69  }
70  return mcc;
71  }
72 
73  unsigned
75  unsigned depth = 0;
76  ModuleCallingContext const* mcc = this;
77  while(mcc->type() == ParentContext::Type::kModule) {
78  ++depth;
79  mcc = mcc->moduleCallingContext();
80  }
81  if(mcc->type() == ParentContext::Type::kInternal) {
82  ++depth;
83  mcc = mcc->internalContext()->moduleCallingContext();
84  }
85  while(mcc->type() == ParentContext::Type::kModule) {
86  ++depth;
87  mcc = mcc->moduleCallingContext();
88  }
89  return depth;
90  }
91 
92  std::ostream& operator<<(std::ostream& os, ModuleCallingContext const& mcc) {
93  os << "ModuleCallingContext state = ";
94  switch (mcc.state()) {
96  os << "Invalid";
97  break;
99  os << "Prefetching";
100  break;
102  os << "Running";
103  break;
104  }
105  os << "\n";
107  return os;
108  }
109  if(mcc.moduleDescription()) {
110  os << " moduleDescription: " << *mcc.moduleDescription() << "\n";
111  }
112  os << " " << mcc.parent();
113  if(mcc.previousModuleOnThread()) {
115  os << " previousModuleOnThread: same as parent module\n";
116  } else {
117  os << " previousModuleOnThread: " << *mcc.previousModuleOnThread();
118  }
119  }
120  return os;
121  }
122 }
GlobalContext const * globalContext() const
StreamContext const * getStreamContext() const
ModuleCallingContext const * moduleCallingContext() const
ModuleCallingContext const * getTopModuleCallingContext() const
InternalContext const * internalContext() const
ModuleCallingContext const * moduleCallingContext() const
#define nullptr
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:38
ModuleCallingContext const * previousModuleOnThread() const
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