Acheron
Loading...
Searching...
No Matches
acheron::ecs::SystemManager Class Reference

Manages systems and the stages associated with them. More...

#include <system.hpp>

Public Member Functions

template<typename T>
std::shared_ptr< T > RegisterSystem (std::string stage)
 Registers a system.
template<typename T>
void SetSignature (Signature signature)
 Sets a systems signature.
void EntityDespawned (Entity entity)
 Called when an entity is despawned.
SystemStageID GetOrCreateStage (const std::string &name)
 Gets a StageID by name, or creates one if it doesnt exist.
SystemStageID GetStageOrFail (const std::string &name)
 Gets a StageID by name.
void StageBefore (std::string name, std::string after)
 Creates a stage before another.
void StageAfter (std::string name, std::string before)
 Creates a stage before another.
void PopulateStages ()
 Clears and populates ordereredStages.
void EntitySignatureChanged (Entity entity, Signature signature)
 Updates the system signature based on the entities new signature.

Public Attributes

std::unordered_map< std::string, SystemStageID > nameToID
 Maps a stage name to its respective ID.
std::unordered_map< SystemStageID, std::vector< SystemStageID > > edges
 How a stage is associated with one another.
std::vector< SystemStagestages
 A list of registered stages.
std::vector< SystemStageID > orderedStages
 Stages put in order by PopulateStages.
std::unordered_map< SystemStageID, std::vector< std::shared_ptr< System > > > stageSystems
std::unordered_map< std::string, std::shared_ptr< System > > systems
 A map of systems and their name.
std::unordered_map< std::string, Signature > signatures
 A map of systems name and the signature associated with them.
SystemStageID counter
bool per_entity = true

Detailed Description

Manages systems and the stages associated with them.

Member Function Documentation

◆ EntityDespawned()

void SystemManager::EntityDespawned ( Entity entity)

Called when an entity is despawned.

Removes the entity from the entity list that applied to the system

Parameters
entityThe entity that was despawned

◆ EntitySignatureChanged()

void SystemManager::EntitySignatureChanged ( Entity entity,
Signature signature )

Updates the system signature based on the entities new signature.

Parameters
entityThe entities whom system was changed
signatureThe new signature of the entity

◆ GetOrCreateStage()

SystemStageID SystemManager::GetOrCreateStage ( const std::string & name)

Gets a StageID by name, or creates one if it doesnt exist.

Parameters
nameThe name of the stage to create or get
Returns
The ID created or of an existing stage

◆ GetStageOrFail()

SystemStageID SystemManager::GetStageOrFail ( const std::string & name)

Gets a StageID by name.

Parameters
nameThe name of the stage to get
Exceptions
RuntimeError if the stage doesnt exist
Returns
The ID created

◆ RegisterSystem()

template<typename T>
std::shared_ptr< T > acheron::ecs::SystemManager::RegisterSystem ( std::string stage)
inline

Registers a system.

Registers a system to its appropriate stage, and type

Template Parameters
TThe struct that should inherit from System
Parameters
stageThe stage at which the system should be executed
Returns
A pointer to the system registered(usually ignored)
Exceptions
AssertionFail if T doesnt inherit system, or if already registered

◆ SetSignature()

template<typename T>
void acheron::ecs::SystemManager::SetSignature ( Signature signature)
inline

Sets a systems signature.

Template Parameters
TThe struct that should inherit from System
Parameters
signatureThe system signature to apply to T

◆ StageAfter()

void SystemManager::StageAfter ( std::string name,
std::string before )

Creates a stage before another.

Parameters
nameThe name of the system to register after
afterThe system that will be before the registered stage

◆ StageBefore()

void SystemManager::StageBefore ( std::string name,
std::string after )

Creates a stage before another.

Parameters
nameThe name of the system to register before
afterThe system that will be after the registered stage

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