File indexing completed on 2024-05-11 03:34:17
0001 #ifndef FWCore_ServiceRegistry_ModuleCallingContext_h
0002 #define FWCore_ServiceRegistry_ModuleCallingContext_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "FWCore/ServiceRegistry/interface/ParentContext.h"
0018
0019 #include <iosfwd>
0020 #include <cstdint>
0021
0022 namespace cms {
0023 class Exception;
0024 }
0025 namespace edm {
0026
0027 class GlobalContext;
0028 class InternalContext;
0029 class ModuleDescription;
0030 class PlaceInPathContext;
0031 class StreamContext;
0032
0033 class ModuleCallingContext {
0034 public:
0035 typedef ParentContext::Type Type;
0036
0037 enum class State {
0038 kPrefetching,
0039 kRunning,
0040 kInvalid
0041 };
0042
0043 ModuleCallingContext(ModuleDescription const* moduleDescription) noexcept;
0044
0045 ModuleCallingContext(ModuleDescription const* moduleDescription,
0046 std::uintptr_t id,
0047 State state,
0048 ParentContext const& parent,
0049 ModuleCallingContext const* previousOnThread) noexcept;
0050
0051 void setContext(State state, ParentContext const& parent, ModuleCallingContext const* previousOnThread) noexcept;
0052
0053 void setState(State state) noexcept { state_ = state; }
0054
0055 ModuleDescription const* moduleDescription() const noexcept { return moduleDescription_; }
0056 State state() const noexcept { return state_; }
0057 Type type() const noexcept { return parent_.type(); }
0058
0059
0060
0061
0062 std::uintptr_t callID() const noexcept { return id_; }
0063 ParentContext const& parent() const noexcept { return parent_; }
0064 ModuleCallingContext const* moduleCallingContext() const { return parent_.moduleCallingContext(); }
0065 PlaceInPathContext const* placeInPathContext() const { return parent_.placeInPathContext(); }
0066 StreamContext const* streamContext() const { return parent_.streamContext(); }
0067 GlobalContext const* globalContext() const { return parent_.globalContext(); }
0068 InternalContext const* internalContext() const { return parent_.internalContext(); }
0069
0070
0071
0072
0073 StreamContext const* getStreamContext() const noexcept(false);
0074 GlobalContext const* getGlobalContext() const noexcept(false);
0075
0076
0077
0078
0079 ModuleCallingContext const* getTopModuleCallingContext() const noexcept;
0080
0081
0082
0083 unsigned depth() const noexcept;
0084
0085 ModuleCallingContext const* previousModuleOnThread() const noexcept { return previousModuleOnThread_; }
0086
0087 private:
0088 ModuleCallingContext const* previousModuleOnThread_;
0089 ModuleDescription const* moduleDescription_;
0090 ParentContext parent_;
0091 std::uintptr_t id_;
0092 State state_;
0093 };
0094
0095 void exceptionContext(cms::Exception&, ModuleCallingContext const&);
0096 std::ostream& operator<<(std::ostream&, ModuleCallingContext const&);
0097 }
0098 #endif