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() noexcept : type_(Type::kInvalid) { parent_.global = nullptr; }
16 
17  ParentContext::ParentContext(GlobalContext const* global) noexcept : type_(Type::kGlobal) { parent_.global = global; }
18 
19  ParentContext::ParentContext(InternalContext const* internal) noexcept : type_(Type::kInternal) {
20  parent_.internal = internal;
21  }
22 
23  ParentContext::ParentContext(ModuleCallingContext const* module) noexcept : type_(Type::kModule) {
24  parent_.module = module;
25  }
26 
27  ParentContext::ParentContext(PlaceInPathContext const* placeInPath) noexcept : type_(Type::kPlaceInPath) {
28  parent_.placeInPath = placeInPath;
29  }
30 
31  ParentContext::ParentContext(StreamContext const* stream) noexcept : type_(Type::kStream) { parent_.stream = stream; }
32 
34  if (type_ != Type::kModule) {
35  throw Exception(errors::LogicError) << "ParentContext::moduleCallingContext called for incorrect type of context";
36  }
37  return parent_.module;
38  }
39 
41  if (type_ != Type::kPlaceInPath) {
42  throw Exception(errors::LogicError) << "ParentContext::placeInPathContext called for incorrect type of context";
43  }
44  return parent_.placeInPath;
45  }
46 
48  if (type_ != Type::kStream) {
49  throw Exception(errors::LogicError) << "ParentContext::streamContext called for incorrect type of context";
50  }
51  return parent_.stream;
52  }
53 
55  if (type_ != Type::kGlobal) {
56  throw Exception(errors::LogicError) << "ParentContext::globalContext called for incorrect type of context";
57  }
58  return parent_.global;
59  }
60 
62  if (type_ != Type::kInternal) {
63  throw Exception(errors::LogicError) << "ParentContext::internalContext called for incorrect type of context";
64  }
65  return parent_.internal;
66  }
67 
69  switch (type_) {
70  case Type::kGlobal: {
72  }
73  case Type::kModule: {
75  }
76  case Type::kStream: {
78  }
79  case Type::kPlaceInPath: {
81  }
82  default:
83  break;
84  }
85  return false;
86  }
87 
88  std::ostream& operator<<(std::ostream& os, ParentContext const& pc) {
89  if (pc.type() == ParentContext::Type::kGlobal && pc.globalContext()) {
90  os << *pc.globalContext();
91  } else if (pc.type() == ParentContext::Type::kInternal && pc.internalContext()) {
92  os << *pc.internalContext();
93  } else if (pc.type() == ParentContext::Type::kModule && pc.moduleCallingContext()) {
94  os << *pc.moduleCallingContext();
95  } else if (pc.type() == ParentContext::Type::kPlaceInPath && pc.placeInPathContext()) {
96  os << *pc.placeInPathContext();
97  } else if (pc.type() == ParentContext::Type::kStream && pc.streamContext()) {
98  os << *pc.streamContext();
99  } else if (pc.type() == ParentContext::Type::kInvalid) {
100  os << "ParentContext invalid\n";
101  }
102  return os;
103  }
104 } // namespace edm
PlaceInPathContext const * placeInPathContext() const noexcept(false)
InternalContext const * internalContext() const noexcept(false)
StreamContext const * streamContext() const noexcept(false)
ModuleCallingContext const * module
Definition: ParentContext.h:54
union edm::ParentContext::Parent parent_
StreamContext const * stream
Definition: ParentContext.h:56
GlobalContext const * globalContext() const noexcept(false)
StreamContext const * streamContext() const
Definition: PathContext.h:31
ModuleCallingContext const * moduleCallingContext() const noexcept(false)
InternalContext const * internal
Definition: ParentContext.h:53
bool isAtEndTransition() const noexcept
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Type type() const noexcept
Definition: ParentContext.h:38
PlaceInPathContext const * placeInPath
Definition: ParentContext.h:55
bool isAtEndTransition() const
Definition: StreamContext.h:57
bool isAtEndTransition() const
Definition: GlobalContext.h:60
ParentContext const & parent() const noexcept
HLT enums.
ParentContext() noexcept
PathContext const * pathContext() const
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
GlobalContext const * global
Definition: ParentContext.h:52