Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::SystemManager Class Reference

Manages the registration, update, and shutdown of systems. More...

#include <System.h>

Public Member Functions

 SystemManager ()=default
 ~SystemManager ()=default
 SystemManager (const SystemManager &)=delete
SystemManageroperator= (const SystemManager &)=delete
template<typename T, typename... Args>
void RegisterSystem (bool dedicated, const std::string &id, Args &&... args)
 Registers a new system of type T.
void UpdateAll (float ts)
 Updates all non-dedicated systems.
void DispatchEvent (Event &e)
 Dispatches an event to all registered systems' OnEvent functions.
void ShutdownAll ()
 Shuts down all registered systems.
bool ShutdownSystem (const std::string &id)
 Shuts down a specific system identified by its unique ID.

Detailed Description

Manages the registration, update, and shutdown of systems.

SystemManager is a singleton that dynamically registers systems using a unique identifier. It supports both systems running in the main loop and those running on dedicated threads.

Constructor & Destructor Documentation

◆ SystemManager() [1/2]

Raven::SystemManager::SystemManager ( )
default

◆ ~SystemManager()

Raven::SystemManager::~SystemManager ( )
default

◆ SystemManager() [2/2]

Raven::SystemManager::SystemManager ( const SystemManager & )
delete

Member Function Documentation

◆ DispatchEvent()

void Raven::SystemManager::DispatchEvent ( Event & e)

Dispatches an event to all registered systems' OnEvent functions.

This method will iterate over all systems and forward the event to their respective OnEvent function, allowing systems to react to events.

Parameters
eThe event to dispatch.

◆ operator=()

SystemManager & Raven::SystemManager::operator= ( const SystemManager & )
delete

◆ RegisterSystem()

template<typename T, typename... Args>
void Raven::SystemManager::RegisterSystem ( bool dedicated,
const std::string & id,
Args &&... args )
inline

Registers a new system of type T.

Dynamically allocates the system and wraps it in a SystemHolder. The system is identified by a unique string and can optionally be run on a dedicated thread.

Template Parameters
TThe system type.
ArgsConstructor argument types for the system.
Parameters
dedicatedIf true, the system will run on its own thread.
idA unique string identifier for the system.
argsArguments forwarded to the system's constructor.

◆ ShutdownAll()

void Raven::SystemManager::ShutdownAll ( )

Shuts down all registered systems.

Signals each system to stop running by setting Running to false, calls the system's Shutdown function, joins dedicated threads if necessary, and destroys the system instance. Finally, clears the systems map.

◆ ShutdownSystem()

bool Raven::SystemManager::ShutdownSystem ( const std::string & id)

Shuts down a specific system identified by its unique ID.

If the system is found, it stops its execution, cleans up its resources, and removes it from the systems map.

Parameters
idThe unique identifier of the system to shut down.
Returns
true if the system was found and shut down, false otherwise.

◆ UpdateAll()

void Raven::SystemManager::UpdateAll ( float ts)

Updates all non-dedicated systems.

This function should be called from the main loop to update systems that are not running on a dedicated thread.


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