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), moduleDescription_(moduleDescription), parent_(), state_(State::kInvalid) {}
16 
18  State state,
19  ParentContext const& parent,
20  ModuleCallingContext const* previousOnThread)
21  : previousModuleOnThread_(previousOnThread),
22  moduleDescription_(moduleDescription),
23  parent_(parent),
24  state_(state) {}
25 
27  ParentContext const& parent,
28  ModuleCallingContext const* previousOnThread) {
29  state_ = state;
30  parent_ = parent;
31  previousModuleOnThread_ = previousOnThread;
32  }
33 
37  return mcc->placeInPathContext()->pathContext()->streamContext();
38  } else if (mcc->type() != ParentContext::Type::kStream) {
40  << "ModuleCallingContext::getStreamContext() called in context not linked to a StreamContext\n";
41  }
42  return mcc->streamContext();
43  }
44 
47  if (mcc->type() != ParentContext::Type::kGlobal) {
49  << "ModuleCallingContext::getGlobalContext() called in context not linked to a GlobalContext\n";
50  }
51  return mcc->globalContext();
52  }
53 
55  ModuleCallingContext const* mcc = this;
56  while (mcc->type() == ParentContext::Type::kModule) {
57  mcc = mcc->moduleCallingContext();
58  }
59  if (mcc->type() == ParentContext::Type::kInternal) {
60  mcc = mcc->internalContext()->moduleCallingContext();
61  }
62  while (mcc->type() == ParentContext::Type::kModule) {
63  mcc = mcc->moduleCallingContext();
64  }
65  return mcc;
66  }
67 
68  unsigned ModuleCallingContext::depth() const {
69  unsigned depth = 0;
70  ModuleCallingContext const* mcc = this;
71  while (mcc->type() == ParentContext::Type::kModule) {
72  ++depth;
73  mcc = mcc->moduleCallingContext();
74  }
75  if (mcc->type() == ParentContext::Type::kInternal) {
76  ++depth;
77  mcc = mcc->internalContext()->moduleCallingContext();
78  }
79  while (mcc->type() == ParentContext::Type::kModule) {
80  ++depth;
81  mcc = mcc->moduleCallingContext();
82  }
83  return depth;
84  }
85 
87  ModuleCallingContext const* imcc = &mcc;
88  while ((imcc->type() == ParentContext::Type::kModule) or (imcc->type() == ParentContext::Type::kInternal)) {
89  std::ostringstream iost;
91  iost << "Prefetching for module ";
92  } else {
93  iost << "Calling method for module ";
94  }
95  iost << imcc->moduleDescription()->moduleName() << "/'" << imcc->moduleDescription()->moduleLabel() << "'";
96 
97  if (imcc->type() == ParentContext::Type::kInternal) {
98  iost << " (probably inside some kind of mixing module)";
99  imcc = imcc->internalContext()->moduleCallingContext();
100  } else {
101  imcc = imcc->moduleCallingContext();
102  }
103  ex.addContext(iost.str());
104  }
105  std::ostringstream ost;
107  ost << "Prefetching for module ";
108  } else {
109  ost << "Calling method for module ";
110  }
111  ost << imcc->moduleDescription()->moduleName() << "/'" << imcc->moduleDescription()->moduleLabel() << "'";
112  ex.addContext(ost.str());
113 
114  if (imcc->type() == ParentContext::Type::kPlaceInPath) {
115  ost.str("");
116  ost << "Running path '";
117  ost << imcc->placeInPathContext()->pathContext()->pathName() << "'";
118  ex.addContext(ost.str());
119  auto streamContext = imcc->placeInPathContext()->pathContext()->streamContext();
120  if (streamContext) {
121  ost.str("");
122  edm::exceptionContext(ost, *streamContext);
123  ex.addContext(ost.str());
124  }
125  } else {
126  if (imcc->type() == ParentContext::Type::kStream) {
127  ost.str("");
128  edm::exceptionContext(ost, *(imcc->streamContext()));
129  ex.addContext(ost.str());
130  } else if (imcc->type() == ParentContext::Type::kGlobal) {
131  ost.str("");
132  edm::exceptionContext(ost, *(imcc->globalContext()));
133  ex.addContext(ost.str());
134  }
135  }
136  }
137 
138  std::ostream& operator<<(std::ostream& os, ModuleCallingContext const& mcc) {
139  os << "ModuleCallingContext state = ";
140  switch (mcc.state()) {
142  os << "Invalid";
143  break;
145  os << "Prefetching";
146  break;
148  os << "Running";
149  break;
150  }
151  os << "\n";
153  return os;
154  }
155  if (mcc.moduleDescription()) {
156  os << " moduleDescription: " << *mcc.moduleDescription() << "\n";
157  }
158  os << " " << mcc.parent();
159  if (mcc.previousModuleOnThread()) {
161  os << " previousModuleOnThread: same as parent module\n";
162  } else {
163  os << " previousModuleOnThread: " << *mcc.previousModuleOnThread();
164  }
165  }
166  return os;
167  }
168 } // 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:165
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 tbale.
std::string const & moduleLabel() const
GlobalContext const * getGlobalContext() const
ParentContext const & parent() const