Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
AScheduler.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IScheduler.hpp"
4
5#include "system/System.hpp"
6
7#include <set>
8#include <typeindex>
9
10namespace Engine::Scheduler {
15class AScheduler : public IScheduler {
16 public:
20 explicit AScheduler(Core &core) : _core(core) {}
21
26 inline decltype(auto) GetSystems() { return _enabledSystemsList.GetSystems(); }
27
34 template <typename... TSystems> inline decltype(auto) AddSystems(TSystems... systems)
35 {
36 return _enabledSystemsList.AddSystems(systems...);
37 }
38
42
46
54 void RunSystem(const SystemBase *system, Core &core);
55
61 inline bool ShouldRunNextScheduler() const { return _shouldRunNextScheduler; }
62
67 inline SchedulerErrorPolicy GetErrorPolicy() const override { return _errorPolicy; }
68
73 inline void SetErrorPolicy(SchedulerErrorPolicy errorPolicy) override { _errorPolicy = errorPolicy; }
74
79
80 protected:
86
87 private:
94 bool _shouldRunSystems = true;
101};
102} // namespace Engine::Scheduler
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
void Enable(FunctionUtils::FunctionID id)
Enable a system.
Definition AScheduler.cpp:24
SchedulerErrorPolicy GetErrorPolicy() const override
Get the error policy of the scheduler.
Definition AScheduler.hpp:67
void Disable(FunctionUtils::FunctionID id)
Disable a system.
Definition AScheduler.cpp:8
void Remove(FunctionUtils::FunctionID id)
Remove a system from the scheduler.
Definition AScheduler.cpp:82
bool _shouldRunNextScheduler
A state if the next scheduler should be executed or not. This is mainly used to handle the error poli...
Definition AScheduler.hpp:97
decltype(auto) GetSystems()
Get systems inside the scheduler.
Definition AScheduler.hpp:26
AScheduler(Core &core)
Constructor of the AScheduler class.
Definition AScheduler.hpp:20
SystemContainer _disabledSystemsList
List of disabled systems in the scheduler.
Definition AScheduler.hpp:91
SystemContainer _enabledSystemsList
List of enabled systems in the scheduler.
Definition AScheduler.hpp:89
void SetErrorPolicy(SchedulerErrorPolicy errorPolicy) override
Set the error policy of the scheduler.
Definition AScheduler.hpp:73
bool ShouldRunNextScheduler() const
Get whether the next scheduler should run or not. This is mainly set by the error policy of the sched...
Definition AScheduler.hpp:61
decltype(auto) AddSystems(TSystems... systems)
Add systems to the scheduler.
Definition AScheduler.hpp:34
Core & _core
Reference to the core.
Definition AScheduler.hpp:85
bool _shouldRunSystems
A state if the systems of the scheduler should be executed or not. If false, the scheduler will skip ...
Definition AScheduler.hpp:94
void RunSystem(const SystemBase *system, Core &core)
Execute a system.
Definition AScheduler.cpp:40
SchedulerErrorPolicy _errorPolicy
The error policy of the scheduler. It defines how the scheduler should handle errors that occur durin...
Definition AScheduler.hpp:100
Interface for the schedulers. A scheduler is responsible for running systems according to a specific ...
Definition IScheduler.hpp:27
Container class for managing multiple systems.
Definition System.hpp:24
Definition AScheduler.cpp:7
SchedulerErrorPolicy
Enum that defines how the scheduler will handle errors.
Definition IScheduler.hpp:11
@ LogAndContinue
Just log the error and resume execution.
Definition IScheduler.hpp:17
FunctionUtils::BaseFunction< void, Core & > SystemBase
Definition System.hpp:17
std::size_t FunctionID
FunctionID class to represent a unique identifier for functions.
Definition FunctionID.hpp:9