struct
ComponentPackComponentPack
class for holding a set of runtime components that make up a coherent inter-dependent runtime
Public types
Constructors, destructors, conversion operators
- ComponentPack() defaulted
- ~ComponentPack()
Public functions
-
template<typename T, typename... StartupDeps, typename... RuntimeDeps, typename... Cons>auto registerComponent(T** ref, typename BaseComponent::
StartupDepsPack<StartupDeps...>, typename BaseComponent:: RuntimeDepsPack<RuntimeDeps...>, Cons && ... cons) -> registry:: AutoHandlerType - Idempotent registration of a component into this runtime pack.
-
template<typename T>void add()
- Add a component to the pack. It will be constructed along with all its dependencies. It must be registered via
registerComponent
before adding. - void construct()
- Construct all added components along with dependencies transitively.
- void destruct()
- Destruct all live components. Can be re-constructed by invoking
construct
. - auto progress(TimeType current_time) -> int
- Invoke the progress function on all pollable components.
- auto needsCurrentTime() -> bool
- Needs current time.
-
template<typename T>auto extractComponent(std::string const& name) -> std::unique_ptr<T>
- Extract the first component from a running pack that matches
name
. - void foreach(std::function<void(BaseComponent*)> apply)
- Apply a function to each live component in the pack.
- auto isLive() const -> bool
- Query whether the
ComponentPack
is live.
Function documentation
template<typename T, typename... StartupDeps, typename... RuntimeDeps, typename... Cons>
registry:: AutoHandlerType vt:: runtime:: component:: ComponentPack:: registerComponent(T** ref,
typename BaseComponent:: StartupDepsPack<StartupDeps...>,
typename BaseComponent:: RuntimeDepsPack<RuntimeDeps...>,
Cons && ... cons)
Idempotent registration of a component into this runtime pack.
Parameters | |
---|---|
ref out | dumb pointer for access outside |
cons in | constructor arguments for the component—bound at registration time |
Returns | registry:: with type ID for component |
\internalComponent dependencies are specified with variadic template parameters in StartupDepsPack
and RuntimeDepsPack
. Registration does not imply the component will be created; it must be added subsequently to be enabled. It simply declares its existence and connectivity with other components.
Startup dependencies are ones that are required for the component to be constructed and fire the initialize method. Additionally, and importantly, they determine the order (reverse topological) in which components are torn down or finalized. Both orders are sensitive as components require other components to be live during construction/initialization and during finalization. Runtime dependencies indicate that a component requires another component to function and thus needs them to be loaded. Thus, for instance, if a VT runtime is created with just an ActiveMessenger
, the runtime will add all the startup dependencies and runtime dependencies to create a runtime with a working ActiveMessenger
that is able to function.
bool vt:: runtime:: component:: ComponentPack:: needsCurrentTime()
Needs current time.
Returns | whether any component needs the current time on the progress call |
---|
template<typename T>
std::unique_ptr<T> vt:: runtime:: component:: ComponentPack:: extractComponent(std::string const& name)
Extract the first component from a running pack that matches name
.
Parameters | |
---|---|
name in | the name of the component to remove |
Returns | pointer to the component to extract |
\internalThe component will be cast to the specified component type T
.
void vt:: runtime:: component:: ComponentPack:: foreach(std::function<void(BaseComponent*)> apply)
Apply a function to each live component in the pack.
Parameters | |
---|---|
apply in | function that takes a BaseComponent to apply over pack |
bool vt:: runtime:: component:: ComponentPack:: isLive() const
Query whether the ComponentPack
is live.
Returns | whether it is live |
---|