Skip to main content

System Class

Type-erased wrapper for game logic processors. More...

Declaration

class helios::engine::runtime::world::System { ... }

Public Constructors Index

System ()=default

Default constructor creating an empty System. More...

template <typename T>
System (T system)

Wraps a concrete system in a type-erased System. More...

System (const System &)=delete
System (System &&) noexcept=default

Public Operators Index

System &operator= (const System &)=delete
System &operator= (System &&)=default

Public Member Functions Index

voidupdate (UpdateContext &updateContext) noexcept

Delegates to the wrapped system's `update()` method. More...

voidinit (GameWorld &gameWorld) noexcept

Delegates to the wrapped system's `init()` method, if present. More...

void *underlying () noexcept

Returns a type-erased pointer to the wrapped system instance. More...

const void *underlying () const noexcept

Returns a type-erased pointer to the wrapped system instance. More...

Private Member Attributes Index

std::unique_ptr< Concept >pimpl_

Description

Type-erased wrapper for game logic processors.

System uses the Concept/Model pattern to erase the concrete system type. Concrete systems are plain classes that satisfy `HasUpdate<T>` — they do not inherit from System.

The internal `Concept` base defines the virtual interface, and `Model<T>` adapts the concrete type T, owning it by value. `init()` is conditionally forwarded if `HasInit<T>` is satisfied.

System is move-only (non-copyable).

See Also

HasUpdate

See Also

HasInit

See Also

SystemRegistry

See Also

https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Erasure

Definition at line 43 of file System.ixx.

Public Constructors

System()

helios::engine::runtime::world::System::System ()
default

Default constructor creating an empty System.

Definition at line 98 of file System.ixx.

Referenced by operator=, operator=, System and System.

System()

template <typename T>
helios::engine::runtime::world::System::System (T system)
inline explicit

Wraps a concrete system in a type-erased System.

Template Parameters
T

The concrete system type, must satisfy `HasUpdate<T>`.

Parameters
system

The concrete system instance to wrap (moved into internal storage).

Definition at line 109 of file System.ixx.

109 explicit System(T system) : pimpl_(std::make_unique<Model<T>>(std::move(system))) {}

System()

helios::engine::runtime::world::System::System (const System &)
delete

Definition at line 111 of file System.ixx.

Reference System.

System()

helios::engine::runtime::world::System::System (System &&)
noexcept default

Definition at line 115 of file System.ixx.

Reference System.

Public Operators

operator=()

System & helios::engine::runtime::world::System::operator= (const System &)
delete

Definition at line 112 of file System.ixx.

Reference System.

operator=()

System & helios::engine::runtime::world::System::operator= (System &&)
default

Definition at line 114 of file System.ixx.

Reference System.

Public Member Functions

init()

void helios::engine::runtime::world::System::init (GameWorld & gameWorld)
inline noexcept

Delegates to the wrapped system's `init()` method, if present.

If the concrete type satisfies `HasInit<T>`, its `init()` is called. Otherwise this is a no-op.

Parameters
gameWorld

The GameWorld for one-time initialization.

Precondition

System must be initialized (pimpl_ != nullptr).

Definition at line 140 of file System.ixx.

140 void init(GameWorld& gameWorld) noexcept {
141 assert(pimpl_ && "System not initialized");
142 pimpl_->init(gameWorld);
143 }

underlying()

void * helios::engine::runtime::world::System::underlying ()
inline nodiscard noexcept

Returns a type-erased pointer to the wrapped system instance.

Returns

Pointer to the underlying concrete system.

Precondition

System must be initialized (pimpl_ != nullptr).

Definition at line 152 of file System.ixx.

152 [[nodiscard]] void* underlying() noexcept {
153 assert(pimpl_ && "System not initialized");
154 return pimpl_->underlying();
155 }

underlying()

const void * helios::engine::runtime::world::System::underlying ()
inline nodiscard noexcept

Returns a type-erased pointer to the wrapped system instance.

Returns

Pointer to the underlying concrete system.

Precondition

System must be initialized (pimpl_ != nullptr).

Definition at line 160 of file System.ixx.

160 [[nodiscard]] const void* underlying() const noexcept {
161 assert(pimpl_ && "System not initialized");
162 return pimpl_->underlying();
163 }

update()

void helios::engine::runtime::world::System::update (UpdateContext & updateContext)
inline noexcept

Delegates to the wrapped system's `update()` method.

Parameters
updateContext

The current frame's update context.

Precondition

System must be initialized (pimpl_ != nullptr).

Definition at line 125 of file System.ixx.

125 void update(UpdateContext& updateContext) noexcept {
126 assert(pimpl_ && "System not initialized");
127 pimpl_->update(updateContext);
128 }

Reference update.

Referenced by update.

Private Member Attributes

pimpl_

std::unique_ptr<Concept> helios::engine::runtime::world::System::pimpl_

Definition at line 91 of file System.ixx.

91 std::unique_ptr<Concept> pimpl_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.