Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::SystemManager Class Reference

Manages Systems in the ECS model. Allows for System to be added, but not invoked. More...

#include <systemManager.h>

Inheritance diagram for Saga::SystemManager:
Collaboration diagram for Saga::SystemManager:

Public Types

enum class  Stage {
  Awake , Start , PreUpdate , Update ,
  LateUpdate , FixedUpdate , LateFixedUpdate , Draw ,
  Cleanup
}
 Stages in the Saga engine where systems can be set to run in. Awake is a stage that happens at the very start of an entity. Start happens on the firsts frame. Every frame thereafter, PreUpdate, Update, and LateUpdate is called. FixedUpdate is called on every physics frame, and so is LateFixedUpdate. The Draw stage happens at the end of every frame, where we have to render the output to the screen. More...
 
enum  Id : uint64_t
 Used for id of Systems. More...
 

Public Member Functions

 SystemManager ()
 
virtual ~SystemManager ()
 
template<typename ... DataType>
EventMap::Id addStagedSystem (std::shared_ptr< System< DataType... > > system, Stage stage=Stage::Update)
 Add a staged System to the list of systems.
 
void removeStagedSystem (EventMap::Id id, Stage stage=Stage::Update)
 Remove a staged System.
 
template<typename Event , typename ... DataType>
EventMap::Id addEventSystem (Event event, std::shared_ptr< System< DataType... > > system)
 Add an event System. Event systems are Systems triggerable by events broadcasted by the program, and not neccessarily the stages in normal execution. These Systems only respond to when events are being broadcasted.
 
template<typename Event >
void removeEventSystem (Event event, EventMap::Id id)
 Remove the System from being called when an event is broadcasted.
 
template<typename Event , typename ... DataType>
EventMap::Id addEventSystem (Event event, Saga::Entity entity, std::shared_ptr< System< Saga::Entity, DataType... > > system)
 Add an event System specific to an entity. This event System will be triggered when that event is delivered to the entity.
 
template<typename Event >
void removeEventSystem (Event event, Saga::Entity entity, EventMap::Id id)
 Remove the System from being called when an event is delivered.
 
EventMap::Id addKeyboardEventSystem (int key, System< int > system)
 Add a System to respond to a keyboard input.
 
void removeKeyboardEventSystem (int key, EventMap::Id id)
 Remove a keyboard System.
 
EventMap::Id addMouseEventSystem (int key, System< int > system)
 Add a System to respond to a mouse button inputs.
 
void removeMouseEventSystem (int key, EventMap::Id id)
 Remove a System from responding to mouse button inputs.
 
EventMap::Id addMousePosSystem (System< double, double > system)
 Add a System to receive mouse position.
 
void removeMousePosSystem (EventMap::Id id)
 
EventMap::Id addScrollSystem (System< double > system)
 Add a System to receive scroll input.
 
void removeScrollSystem (EventMap::Id id)
 
EventMap::Id addWindowResizeSystem (System< int, int > system)
 Add a System to receive when the window resize.
 
void removeWindowResizeSystem (EventMap::Id id)
 Remove a resize System.
 

Protected Types

enum class  OtherInput { MOUSE_POS , SCROLL , WINDOW_RESIZE }
 Types of input events, with button events excluded. More...
 

Static Protected Member Functions

static auto id_value () -> uint64_t &
 

Protected Attributes

EventMap stagedSystemsMap
 Map between Stage and Systems.
 
std::unordered_map< int, EventMapeventSystemsMap
 Maps entity to an EventMap that maps Event to System.
 
EventMap keyboardInputMap
 
EventMap mouseInputMap
 
EventMap otherInputMap
 

Detailed Description

Manages Systems in the ECS model. Allows for System to be added, but not invoked.

Member Enumeration Documentation

◆ Id

enum Saga::SystemManager::Id : uint64_t

Used for id of Systems.

◆ OtherInput

enum class Saga::SystemManager::OtherInput
strongprotected

Types of input events, with button events excluded.

Enumerator
MOUSE_POS 
SCROLL 
WINDOW_RESIZE 

◆ Stage

enum class Saga::SystemManager::Stage
strong

Stages in the Saga engine where systems can be set to run in. Awake is a stage that happens at the very start of an entity. Start happens on the firsts frame. Every frame thereafter, PreUpdate, Update, and LateUpdate is called. FixedUpdate is called on every physics frame, and so is LateFixedUpdate. The Draw stage happens at the end of every frame, where we have to render the output to the screen.

Enumerator
Awake 
Start 
PreUpdate 
Update 
LateUpdate 
FixedUpdate 
LateFixedUpdate 
Draw 
Cleanup 

Constructor & Destructor Documentation

◆ SystemManager()

Saga::SystemManager::SystemManager ( )

◆ ~SystemManager()

Saga::SystemManager::~SystemManager ( )
virtual

Member Function Documentation

◆ addEventSystem() [1/2]

template<typename Event , typename ... DataType>
EventMap::Id Saga::SystemManager::addEventSystem ( Event  event,
Saga::Entity  entity,
std::shared_ptr< System< Saga::Entity, DataType... > >  system 
)

Add an event System specific to an entity. This event System will be triggered when that event is delivered to the entity.

Template Parameters
Eventcan be anything castable to an integer.
DataTypethe data type the System accepts as argument.
Parameters
event
entity
system
Returns
EventMap::Id id of the System, can be used to remove it later.

◆ addEventSystem() [2/2]

template<typename Event , typename ... DataType>
EventMap::Id Saga::SystemManager::addEventSystem ( Event  event,
std::shared_ptr< System< DataType... > >  system 
)

Add an event System. Event systems are Systems triggerable by events broadcasted by the program, and not neccessarily the stages in normal execution. These Systems only respond to when events are being broadcasted.

Template Parameters
Eventcould be anything castable to an integer.
DataTypethe data types that the Systems that receive these events accept.
Parameters
eventthe event.
systemthe System to add.
Returns
EventMap::Id id of the System, can be used to remove the system later

◆ addKeyboardEventSystem()

EventMap::Id Saga::SystemManager::addKeyboardEventSystem ( int  key,
System< int >  system 
)

Add a System to respond to a keyboard input.

Parameters
keykey as an GLFW enum.
systemSystem to receive the key input.
Returns
EventMap::Id id of the event, can be used to remove it later.
Here is the call graph for this function:

◆ addMouseEventSystem()

EventMap::Id Saga::SystemManager::addMouseEventSystem ( int  key,
System< int >  system 
)

Add a System to respond to a mouse button inputs.

Parameters
keykey as an GLFW enum.
system
Returns
EventMap::Id
Here is the call graph for this function:

◆ addMousePosSystem()

EventMap::Id Saga::SystemManager::addMousePosSystem ( System< double, double >  system)

Add a System to receive mouse position.

Parameters
systemmust accept <double, double> as the position of the mouse in screen space.
Returns
EventMap::Id
Here is the call graph for this function:

◆ addScrollSystem()

EventMap::Id Saga::SystemManager::addScrollSystem ( System< double >  system)

Add a System to receive scroll input.

Parameters
systemmust accept <double> as the amount of pixels scrolled.
Returns
EventMap::Id
Here is the call graph for this function:

◆ addStagedSystem()

template<typename ... DataType>
EventMap::Id Saga::SystemManager::addStagedSystem ( std::shared_ptr< System< DataType... > >  system,
Stage  stage = Stage::Update 
)

Add a staged System to the list of systems.

Template Parameters
DataTypethe data types that the System accepts.
Parameters
system
stagewhich stage is the System attached to. When this stage is invoked, all systems attached to the stage is invoked.
Returns
EventMap::Id id of the System, can be used to remove the system later.
Here is the call graph for this function:

◆ addWindowResizeSystem()

EventMap::Id Saga::SystemManager::addWindowResizeSystem ( System< int, int >  system)

Add a System to receive when the window resize.

Parameters
systemmust accept <int,int> as the dimensions of the window after resized.
Returns
EventMap::Id
Here is the call graph for this function:

◆ id_value()

static auto Saga::SystemManager::id_value ( ) -> uint64_t &
inlinestaticprotected

◆ removeEventSystem() [1/2]

template<typename Event >
void Saga::SystemManager::removeEventSystem ( Event  event,
EventMap::Id  id 
)

Remove the System from being called when an event is broadcasted.

Template Parameters
Eventcan be anything castable to an integer.
Parameters
eventthe event.
idthe id of the System to be removed.

◆ removeEventSystem() [2/2]

template<typename Event >
void Saga::SystemManager::removeEventSystem ( Event  event,
Saga::Entity  entity,
EventMap::Id  id 
)

Remove the System from being called when an event is delivered.

Template Parameters
Eventcan be anything castable to an int.
Parameters
event
entity
id

◆ removeKeyboardEventSystem()

void Saga::SystemManager::removeKeyboardEventSystem ( int  key,
EventMap::Id  id 
)

Remove a keyboard System.

Parameters
key
id
Here is the call graph for this function:

◆ removeMouseEventSystem()

void Saga::SystemManager::removeMouseEventSystem ( int  key,
EventMap::Id  id 
)

Remove a System from responding to mouse button inputs.

Parameters
keykey as an GLFW enum.
id
Here is the call graph for this function:

◆ removeMousePosSystem()

void Saga::SystemManager::removeMousePosSystem ( EventMap::Id  id)
Here is the call graph for this function:

◆ removeScrollSystem()

void Saga::SystemManager::removeScrollSystem ( EventMap::Id  id)
Here is the call graph for this function:

◆ removeStagedSystem()

void Saga::SystemManager::removeStagedSystem ( EventMap::Id  id,
Stage  stage = Stage::Update 
)

Remove a staged System.

Parameters
idthe id of the system to be removed.
stagethe stageSof the System.
See also
Stage
Here is the call graph for this function:

◆ removeWindowResizeSystem()

void Saga::SystemManager::removeWindowResizeSystem ( EventMap::Id  id)

Remove a resize System.

Parameters
id
Here is the call graph for this function:

Member Data Documentation

◆ eventSystemsMap

std::unordered_map<int, EventMap> Saga::SystemManager::eventSystemsMap
protected

Maps entity to an EventMap that maps Event to System.

◆ keyboardInputMap

EventMap Saga::SystemManager::keyboardInputMap
protected

◆ mouseInputMap

EventMap Saga::SystemManager::mouseInputMap
protected

◆ otherInputMap

EventMap Saga::SystemManager::otherInputMap
protected

◆ stagedSystemsMap

EventMap Saga::SystemManager::stagedSystemsMap
protected

Map between Stage and Systems.


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