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 <list>
8#include <set>
9#include <typeindex>
10
11namespace Engine::Scheduler {
16class AScheduler : public IScheduler {
17 public:
21 explicit AScheduler(Core &core);
22
26 const std::list<std::unique_ptr<SystemBase>> &GetSystems();
27
33 template <typename... TSystems> decltype(auto) AddSystems(TSystems... systems);
34
38
42
49 void RunSystem(const SystemBase *system, Core &core);
50
54 bool ShouldRunNextScheduler() const;
55
59 SchedulerErrorPolicy GetErrorPolicy() const override;
60
64 void SetErrorPolicy(SchedulerErrorPolicy errorPolicy) override;
65
70
71 protected:
77
78 private:
85 bool _shouldRunSystems = true;
92};
93} // namespace Engine::Scheduler
94
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:34
SchedulerErrorPolicy GetErrorPolicy() const override
Get the error policy of the scheduler.
Definition AScheduler.cpp:14
void Disable(FunctionUtils::FunctionID id)
Disable a system.
Definition AScheduler.cpp:18
void Remove(FunctionUtils::FunctionID id)
Remove a system from the scheduler.
Definition AScheduler.cpp:92
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:88
const std::list< std::unique_ptr< SystemBase > > & GetSystems()
Get systems inside the scheduler.
Definition AScheduler.cpp:10
AScheduler(Core &core)
Constructor of the AScheduler class.
Definition AScheduler.cpp:8
SystemContainer _disabledSystemsList
List of disabled systems in the scheduler.
Definition AScheduler.hpp:82
SystemContainer _enabledSystemsList
List of enabled systems in the scheduler.
Definition AScheduler.hpp:80
void SetErrorPolicy(SchedulerErrorPolicy errorPolicy) override
Set the error policy of the scheduler.
Definition AScheduler.cpp:16
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.cpp:12
decltype(auto) AddSystems(TSystems... systems)
Add systems to the scheduler.
Definition AScheduler.ipp:4
Core & _core
Reference to the core.
Definition AScheduler.hpp:76
bool _shouldRunSystems
A state if the systems of the scheduler should be executed or not. If false, the scheduler will skip ...
Definition AScheduler.hpp:85
void RunSystem(const SystemBase *system, Core &core)
Execute a system.
Definition AScheduler.cpp:50
SchedulerErrorPolicy _errorPolicy
The error policy of the scheduler. It defines how the scheduler should handle errors that occur durin...
Definition AScheduler.hpp:91
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:25
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:18
std::size_t FunctionID
FunctionID class to represent a unique identifier for functions.
Definition FunctionID.hpp:9