CMS 3D CMS Logo

ModuleCallingContext.cc
Go to the documentation of this file.
9 
10 #include <ostream>
11 
12 namespace edm {
13 
15  : previousModuleOnThread_(nullptr),
16  moduleDescription_(moduleDescription),
17  parent_(),
18  id_(0),
19  state_(State::kInvalid) {}
20 
22  std::uintptr_t id,
23  State state,
24  ParentContext const& parent,
25  ModuleCallingContext const* previousOnThread)
26  : previousModuleOnThread_(previousOnThread),
27  moduleDescription_(moduleDescription),
28  parent_(parent),
29  id_(id),
30  state_(state) {}
31 
33  ParentContext const& parent,
34  ModuleCallingContext const* previousOnThread) {
35  state_ = state;
36  parent_ = parent;
37  previousModuleOnThread_ = previousOnThread;
38  }
39 
43  return mcc->placeInPathContext()->pathContext()->streamContext();
44  } else if (mcc->type() != ParentContext::Type::kStream) {
46  << "ModuleCallingContext::getStreamContext() called in context not linked to a StreamContext\n";
47  }
48  return mcc->streamContext();
49  }
50 
53  if (mcc->type() != ParentContext::Type::kGlobal) {
55  << "ModuleCallingContext::getGlobalContext() called in context not linked to a GlobalContext\n";
56  }
57  return mcc->globalContext();
58  }
59 
61  ModuleCallingContext const* mcc = this;
62  while (mcc->type() == ParentContext::Type::kModule) {
63  mcc = mcc->moduleCallingContext();
64  }
65  if (mcc->type() == ParentContext::Type::kInternal) {
66  mcc = mcc->internalContext()->moduleCallingContext();
67  }
68  while (mcc->type() == ParentContext::Type::kModule) {
69  mcc = mcc->moduleCallingContext();
70  }
71  return mcc;
72  }
73 
74  unsigned ModuleCallingContext::depth() const {
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 
93  ModuleCallingContext const* imcc = &mcc;
94  while ((imcc->type() == ParentContext::Type::kModule) or (imcc->type() == ParentContext::Type::kInternal)) {
95  std::ostringstream iost;
97  iost << "Prefetching for module ";
98  } else {
99  iost << "Calling method for module ";
100  }
101  iost << imcc->moduleDescription()->moduleName() << "/'" << imcc->moduleDescription()->moduleLabel() << "'";
102 
103  if (imcc->type() == ParentContext::Type::kInternal) {
104  iost << " (probably inside some kind of mixing module)";
105  imcc = imcc->internalContext()->moduleCallingContext();
106  } else {
107  imcc = imcc->moduleCallingContext();
108  }
109  ex.addContext(iost.str());
110  }
111  std::ostringstream ost;
113  ost << "Prefetching for module ";
114  } else {
115  ost << "Calling method for module ";
116  }
117  ost << imcc->moduleDescription()->moduleName() << "/'" << imcc->moduleDescription()->moduleLabel() << "'";
118  ex.addContext(ost.str());
119 
120  if (imcc->type() == ParentContext::Type::kPlaceInPath) {
121  ost.str("");
122  ost << "Running path '";
123  ost << imcc->placeInPathContext()->pathContext()->pathName() << "'";
124  ex.addContext(ost.str());
125  auto streamContext = imcc->placeInPathContext()->pathContext()->streamContext();
126  if (streamContext) {
127  ost.str("");
128  edm::exceptionContext(ost, *streamContext);
129  ex.addContext(ost.str());
130  }
131  } else {
132  if (imcc->type() == ParentContext::Type::kStream) {
133  ost.str("");
134  edm::exceptionContext(ost, *(imcc->streamContext()));
135  ex.addContext(ost.str());
136  } else if (imcc->type() == ParentContext::Type::kGlobal) {
137  ost.str("");
138  edm::exceptionContext(ost, *(imcc->globalContext()));
139  ex.addContext(ost.str());
140  }
141  }
142  }
143 
144  std::ostream& operator<<(std::ostream& os, ModuleCallingContext const& mcc) {
145  os << "ModuleCallingContext state = ";
146  switch (mcc.state()) {
148  os << "Invalid";
149  break;
151  os << "Prefetching";
152  break;
154  os << "Running";
155  break;
156  }
157  os << "\n";
159  return os;
160  }
161  if (mcc.moduleDescription()) {
162  os << " moduleDescription: " << *mcc.moduleDescription() << "\n";
163  }
164  os << " " << mcc.parent();
165  if (mcc.previousModuleOnThread()) {
167  os << " previousModuleOnThread: same as parent module\n";
168  } else {
169  os << " previousModuleOnThread: " << *mcc.previousModuleOnThread();
170  }
171  }
172  return os;
173  }
174 } // namespace edm
ModuleCallingContext const * previousModuleOnThread() const
ModuleDescription const * moduleDescription() const
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
InternalContext const * internalContext() const
std::string const & moduleName() const
StreamContext const * streamContext() const
Definition: PathContext.h:31
void setContext(State state, ParentContext const &parent, ModuleCallingContext const *previousOnThread)
ModuleCallingContext const * getTopModuleCallingContext() const
ModuleCallingContext const * moduleCallingContext() const
PlaceInPathContext const * placeInPathContext() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
StreamContext const * streamContext() const
ModuleCallingContext const * moduleCallingContext() const
void addContext(std::string const &context)
Definition: Exception.cc:169
GlobalContext const * globalContext() const
HLT enums.
StreamContext const * getStreamContext() const
ModuleCallingContext(ModuleDescription const *moduleDescription)
PathContext const * pathContext() const
std::string const & pathName() const
Definition: PathContext.h:30
ModuleCallingContext const * previousModuleOnThread_
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
std::string const & moduleLabel() const
GlobalContext const * getGlobalContext() const
ParentContext const & parent() const