CMS 3D CMS Logo

ParentContext.cc
Go to the documentation of this file.
8 
10 
11 #include <ostream>
12 
13 namespace edm {
14 
15  ParentContext::ParentContext() : type_(Type::kInvalid) { parent_.global = nullptr; }
16 
17  ParentContext::ParentContext(GlobalContext const* global) : type_(Type::kGlobal) { parent_.global = global; }
18 
19  ParentContext::ParentContext(InternalContext const* internal) : type_(Type::kInternal) {
20  parent_.internal = internal;
21  }
22 
24 
25  ParentContext::ParentContext(PlaceInPathContext const* placeInPath) : type_(Type::kPlaceInPath) {
26  parent_.placeInPath = placeInPath;
27  }
28 
30 
32  if (type_ != Type::kModule) {
33  throw Exception(errors::LogicError) << "ParentContext::moduleCallingContext called for incorrect type of context";
34  }
35  return parent_.module;
36  }
37 
39  if (type_ != Type::kPlaceInPath) {
40  throw Exception(errors::LogicError) << "ParentContext::placeInPathContext called for incorrect type of context";
41  }
42  return parent_.placeInPath;
43  }
44 
46  if (type_ != Type::kStream) {
47  throw Exception(errors::LogicError) << "ParentContext::streamContext called for incorrect type of context";
48  }
49  return parent_.stream;
50  }
51 
53  if (type_ != Type::kGlobal) {
54  throw Exception(errors::LogicError) << "ParentContext::globalContext called for incorrect type of context";
55  }
56  return parent_.global;
57  }
58 
60  if (type_ != Type::kInternal) {
61  throw Exception(errors::LogicError) << "ParentContext::internalContext called for incorrect type of context";
62  }
63  return parent_.internal;
64  }
65 
67  switch (type_) {
68  case Type::kGlobal: {
70  }
71  case Type::kModule: {
73  }
74  case Type::kStream: {
76  }
77  case Type::kPlaceInPath: {
79  }
80  default:
81  break;
82  }
83  return false;
84  }
85 
86  std::ostream& operator<<(std::ostream& os, ParentContext const& pc) {
87  if (pc.type() == ParentContext::Type::kGlobal && pc.globalContext()) {
88  os << *pc.globalContext();
89  } else if (pc.type() == ParentContext::Type::kInternal && pc.internalContext()) {
90  os << *pc.internalContext();
91  } else if (pc.type() == ParentContext::Type::kModule && pc.moduleCallingContext()) {
92  os << *pc.moduleCallingContext();
93  } else if (pc.type() == ParentContext::Type::kPlaceInPath && pc.placeInPathContext()) {
94  os << *pc.placeInPathContext();
95  } else if (pc.type() == ParentContext::Type::kStream && pc.streamContext()) {
96  os << *pc.streamContext();
97  } else if (pc.type() == ParentContext::Type::kInvalid) {
98  os << "ParentContext invalid\n";
99  }
100  return os;
101  }
102 } // namespace edm
InternalContext const * internalContext() const
Type type() const
Definition: ParentContext.h:38
ModuleCallingContext const * module
Definition: ParentContext.h:54
GlobalContext const * globalContext() const
union edm::ParentContext::Parent parent_
StreamContext const * stream
Definition: ParentContext.h:56
StreamContext const * streamContext() const
Definition: PathContext.h:31
InternalContext const * internal
Definition: ParentContext.h:53
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
bool isAtEndTransition() const
StreamContext const * streamContext() const
PlaceInPathContext const * placeInPath
Definition: ParentContext.h:55
ModuleCallingContext const * moduleCallingContext() const
bool isAtEndTransition() const
Definition: StreamContext.h:57
bool isAtEndTransition() const
Definition: GlobalContext.h:56
PlaceInPathContext const * placeInPathContext() const
HLT enums.
PathContext const * pathContext() const
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
GlobalContext const * global
Definition: ParentContext.h:52
ParentContext const & parent() const