Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Engine::Scheduler::AScheduler Class Reference

AScheduler is an abstract class that implements the IScheduler interface. It provides common functionalities for schedulers, such as enabling/disabling systems and error handling. It also provides a default implementation for the RunSystem function, which executes a system according to the scheduler policy. More...

#include <AScheduler.hpp>

Inheritance diagram for Engine::Scheduler::AScheduler:
Engine::Scheduler::IScheduler Engine::Scheduler::FixedTimeUpdate Engine::Scheduler::RelativeTimeUpdate Engine::Scheduler::Shutdown Engine::Scheduler::Startup Engine::Scheduler::Update RenderingPipeline::Init RenderingPipeline::Setup SchedulerTest1 SchedulerTest2 TestSchedulerA TestSchedulerB

Public Member Functions

 AScheduler (Core &core)
 Constructor of the AScheduler class.
decltype(auto) GetSystems ()
 Get systems inside the scheduler.
template<typename... TSystems>
decltype(auto) AddSystems (TSystems... systems)
 Add systems to the scheduler.
void Disable (FunctionUtils::FunctionID id)
 Disable a system.
void Enable (FunctionUtils::FunctionID id)
 Enable a system.
void RunSystem (const SystemBase *system, Core &core)
 Execute a system.
bool ShouldRunNextScheduler () const
 Get whether the next scheduler should run or not. This is mainly set by the error policy of the scheduler.
SchedulerErrorPolicy GetErrorPolicy () const override
 Get the error policy of the scheduler.
void SetErrorPolicy (SchedulerErrorPolicy errorPolicy) override
 Set the error policy of the scheduler.
void Remove (FunctionUtils::FunctionID id)
 Remove a system from the scheduler.
Public Member Functions inherited from Engine::Scheduler::IScheduler
virtual ~IScheduler ()=default
 Virtual destructor for IScheduler.
virtual void RunSystems (void)=0
 Run the systems according to the scheduler policy.

Protected Attributes

Core_core
 Reference to the core.

Private Attributes

SystemContainer _enabledSystemsList
 List of enabled systems in the scheduler.
SystemContainer _disabledSystemsList
 List of disabled systems in the scheduler.
bool _shouldRunSystems = true
 A state if the systems of the scheduler should be executed or not. If false, the scheduler will skip the execution of its systems. This is mainly used to handle the error policy of the scheduler.
bool _shouldRunNextScheduler = true
 A state if the next scheduler should be executed or not. This is mainly used to handle the error policy of the scheduler.
SchedulerErrorPolicy _errorPolicy = SchedulerErrorPolicy::LogAndContinue
 The error policy of the scheduler. It defines how the scheduler should handle errors that occur during the execution of its systems.

Detailed Description

AScheduler is an abstract class that implements the IScheduler interface. It provides common functionalities for schedulers, such as enabling/disabling systems and error handling. It also provides a default implementation for the RunSystem function, which executes a system according to the scheduler policy.

See also
Engine::Scheduler::IScheduler

Constructor & Destructor Documentation

◆ AScheduler()

Engine::Scheduler::AScheduler::AScheduler ( Core & core)
inlineexplicit

Constructor of the AScheduler class.

Parameters
coreReference to the core.
See also
Engine::Core

Member Function Documentation

◆ AddSystems()

template<typename... TSystems>
decltype(auto) Engine::Scheduler::AScheduler::AddSystems ( TSystems... systems)
inline

Add systems to the scheduler.

Template Parameters
TSystemsTypes of the systems to add.
Parameters
systemsThe systems to add.
Returns
A tuple of FunctionIDs for the added systems. See FunctionUtils::FunctionContainer::AddFunctions for more details.
Todo
put the implementation in the inl file

◆ Disable()

void Engine::Scheduler::AScheduler::Disable ( FunctionUtils::FunctionID id)

Disable a system.

Parameters
idThe system to disable

◆ Enable()

void Engine::Scheduler::AScheduler::Enable ( FunctionUtils::FunctionID id)

Enable a system.

Parameters
idThe system to enable

◆ GetErrorPolicy()

SchedulerErrorPolicy Engine::Scheduler::AScheduler::GetErrorPolicy ( ) const
inlineoverridevirtual

Get the error policy of the scheduler.

Returns
The error policy of the scheduler.
See also
Engine::Scheduler::SchedulerErrorPolicy
Todo
put the implementation in the cpp file, (remove inline)

Implements Engine::Scheduler::IScheduler.

◆ GetSystems()

decltype(auto) Engine::Scheduler::AScheduler::GetSystems ( )
inline

Get systems inside the scheduler.

Returns
A SystemContainer with enabled systems.
See also
Engine::SystemContainer
Todo
put the implementation in the cpp file, (remove inline)

◆ Remove()

void Engine::Scheduler::AScheduler::Remove ( FunctionUtils::FunctionID id)

Remove a system from the scheduler.

Parameters
idThe system to remove.
See also
FunctionUtils::FunctionID

◆ RunSystem()

void Engine::Scheduler::AScheduler::RunSystem ( const SystemBase * system,
Core & core )

Execute a system.

Note
The system will be executed according to the scheduler policy of the scheduler.
Parameters
systemThe system to execute.
coreThe core to pass to the system.
Todo
Remove Core parameter from the function and use the reference to the core stored in the AScheduler class instead.
See also
Engine::SystemBase

◆ SetErrorPolicy()

void Engine::Scheduler::AScheduler::SetErrorPolicy ( SchedulerErrorPolicy errorPolicy)
inlineoverridevirtual

Set the error policy of the scheduler.

Parameters
errorPolicyThe error policy to set.
See also
Engine::Scheduler::SchedulerErrorPolicy
Todo
put the implementation in the cpp file, (remove inline)

Implements Engine::Scheduler::IScheduler.

◆ ShouldRunNextScheduler()

bool Engine::Scheduler::AScheduler::ShouldRunNextScheduler ( ) const
inline

Get whether the next scheduler should run or not. This is mainly set by the error policy of the scheduler.

Returns
true if the next scheduler should run, false otherwise.
Todo

check if we can remove this method and find a cleaner way to handle the error policy of the scheduler.

put the implementation in the cpp file, (remove inline)

Member Data Documentation

◆ _core

Core& Engine::Scheduler::AScheduler::_core
protected

Reference to the core.

Note
This reference is used to pass the core to the systems when executing them. It can also be used by the schedulers to access the core and its resources.
See also
Engine::Core

◆ _disabledSystemsList

SystemContainer Engine::Scheduler::AScheduler::_disabledSystemsList
private

List of disabled systems in the scheduler.

◆ _enabledSystemsList

SystemContainer Engine::Scheduler::AScheduler::_enabledSystemsList
private

List of enabled systems in the scheduler.

◆ _errorPolicy

SchedulerErrorPolicy Engine::Scheduler::AScheduler::_errorPolicy = SchedulerErrorPolicy::LogAndContinue
private

The error policy of the scheduler. It defines how the scheduler should handle errors that occur during the execution of its systems.

◆ _shouldRunNextScheduler

bool Engine::Scheduler::AScheduler::_shouldRunNextScheduler = true
private

A state if the next scheduler should be executed or not. This is mainly used to handle the error policy of the scheduler.

◆ _shouldRunSystems

bool Engine::Scheduler::AScheduler::_shouldRunSystems = true
private

A state if the systems of the scheduler should be executed or not. If false, the scheduler will skip the execution of its systems. This is mainly used to handle the error policy of the scheduler.


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