Parent

ParentContext

Type

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#ifndef FWCore_ServiceRegistry_ParentContext_h
#define FWCore_ServiceRegistry_ParentContext_h

/**\class edm::ParentContext

 Description: This is intended to be used as a member
of ModuleCallingContext.

 Usage:


*/
//
// Original Author: W. David Dagenhart
//         Created: 7/11/2013

#include <iosfwd>

namespace edm {

  class GlobalContext;
  class InternalContext;
  class ModuleCallingContext;
  class PlaceInPathContext;
  class StreamContext;

  class ParentContext {
  public:
    enum class Type { kGlobal, kInternal, kModule, kPlaceInPath, kStream, kInvalid };

    ParentContext() noexcept;
    ParentContext(GlobalContext const*) noexcept;
    ParentContext(InternalContext const*) noexcept;
    ParentContext(ModuleCallingContext const*) noexcept;
    ParentContext(PlaceInPathContext const*) noexcept;
    ParentContext(StreamContext const*) noexcept;

    [[nodiscard]] Type type() const noexcept { return type_; }

    bool isAtEndTransition() const noexcept;

    GlobalContext const* globalContext() const noexcept(false);
    InternalContext const* internalContext() const noexcept(false);
    ModuleCallingContext const* moduleCallingContext() const noexcept(false);
    PlaceInPathContext const* placeInPathContext() const noexcept(false);
    StreamContext const* streamContext() const noexcept(false);

  private:
    Type type_;

    union Parent {
      GlobalContext const* global;
      InternalContext const* internal;
      ModuleCallingContext const* module;
      PlaceInPathContext const* placeInPath;
      StreamContext const* stream;
    } parent_;
  };

  std::ostream& operator<<(std::ostream&, ParentContext const&);
}  // namespace edm
#endif