Engine
Raylib based game framework
Loading...
Searching...
No Matches
SystemManager Class Reference

Manages execution order and lifetime of systems. More...

#include <SystemManager.hpp>

Public Member Functions

 SystemManager (const SystemManager &)=delete
SystemManageroperator= (const SystemManager &)=delete
template<typename SystemT, typename... Args>
std::shared_ptr< SystemT > AddSystem (const u32 priority=1, Args &&... args)
 Constructs a system and adds it to the manager.
template<typename SystemT>
void RemoveSystem ()
 Removes a system from the manager.
template<typename SystemT>
std::shared_ptr< SystemT > GetSystem ()
 Returns a shared pointer to a managed system.
void ClearSystems ()
 Removes and destroys all managed systems.

Friends

class Engine

Detailed Description

Manages execution order and lifetime of systems.

Systems are updated and drawn in ascending priority order. Lower priority values execute first. Systems update and draw before scenes each frame.

Member Function Documentation

◆ AddSystem()

template<typename SystemT, typename... Args>
std::shared_ptr< SystemT > SystemManager::AddSystem ( const u32 priority = 1,
Args &&... args )
inline

Constructs a system and adds it to the manager.

The system is owned by the manager. Systems are sorted by priority immediately after insertion.

Template Parameters
SystemTSystem type (must derive from the System base class)
ArgsSystem constructor argument types
Parameters
priorityExecution priority — lower values run first (default 1)
argsArguments forwarded to the system constructor
Returns
Shared pointer to the created system

Usage:

auto physics = systemManager.AddSystem<PhysicsSystem>(3, gravity);

◆ ClearSystems()

void SystemManager::ClearSystems ( )

Removes and destroys all managed systems.

Called by the Engine destructor.

◆ GetSystem()

template<typename SystemT>
std::shared_ptr< SystemT > SystemManager::GetSystem ( )
inline

Returns a shared pointer to a managed system.

Returns an empty pointer if no system of this type has been added.

Template Parameters
SystemTSystem type to retrieve
Returns
Shared pointer to the system, or nullptr if not found

◆ RemoveSystem()

template<typename SystemT>
void SystemManager::RemoveSystem ( )
inline

Removes a system from the manager.

The system is destroyed when no more shared_ptrs to it remain. Does nothing if the system is not currently managed.

Template Parameters
SystemTSystem type to remove

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