1 #ifndef RADIX_SYSTEM_MANAGER_HPP
2 #define RADIX_SYSTEM_MANAGER_HPP
4 #include <condition_variable>
49 static constexpr decltype(index)
indexUndef =
std::numeric_limits<decltype(index)>::max();
50 static constexpr decltype(lowlink)
lowlinkUndef =
std::numeric_limits<decltype(lowlink)>::max();
87 std::logic_error(
"Execution graph contain loops"),
92 std::logic_error(
"Inserting a System into the execution graph according to"
93 "System::runsAfter() would create a loop"),
110 sysMan(sm), system(s) {}
125 sysMan(sm), system(s) {}
147 template<
class T,
typename... ArgsT>
void addSystem(ArgsT... args) {
148 static_assert(std::is_base_of<System, T>::value,
"T must be a System");
150 if (sm.
systems.size() <= stid) {
153 sm.
systems.at(System::getTypeId<T>()).reset(
new T(sm.
w, std::forward<ArgsT>(args)...));
156 std::forward_as_tuple(sys.
getName()),
157 std::forward_as_tuple(sys));
165 sm.
systemGraph.at(System::getTypeId<T>()).reset(
nullptr);
166 sm.
systems.at(System::getTypeId<T>()).reset(
nullptr);
174 template<
class T> T&
get() {
177 return static_cast<T&
>(*systems.at(System::getTypeId<T>()));
180 template<
class T,
typename... ArgsT>
void add(ArgsT... args) {
185 template<
class T>
void remove() {
System & system
Definition: SystemManager.hpp:123
Definition: GameController.hpp:7
SystemGraphNodeVector & graph
Definition: SystemManager.hpp:42
void dispatchEvent(const Event &)
Definition: SystemManager.cpp:273
Definition: System.hpp:21
std::size_t SystemTypeId
Definition: System.hpp:10
SystemManager & sysMan
Definition: SystemManager.hpp:107
SystemTypeId index
Definition: SystemManager.hpp:47
void add(ArgsT...args)
Definition: SystemManager.hpp:180
std::set< SystemTypeId > predecessors
Definition: SystemManager.hpp:44
void removeSystem()
Definition: SystemManager.hpp:161
bool onStack
Definition: SystemManager.hpp:48
std::vector< std::unique_ptr< SystemGraphNode >> SystemGraphNodeVector
Definition: SystemManager.hpp:38
void addSystem(ArgsT...args)
Definition: SystemManager.hpp:147
Definition: Uncollider.hpp:10
const EventType getType() const
Definition: SystemManager.hpp:103
struct radix::SystemManager::SystemRunner systemRun
System & system
Definition: SystemManager.hpp:108
SystemAddedEvent(SystemManager &sm, System &s)
Definition: SystemManager.hpp:109
RunsBeforeCreatesLoopsException(SystemLoopVector &&slv)
Definition: SystemManager.hpp:86
Definition: TimeDelta.hpp:8
SystemGraphNodeVector systemGraph
Definition: SystemManager.hpp:76
std::mutex runCountMutex
Definition: SystemManager.hpp:68
const EventType getType() const
Definition: SystemManager.hpp:118
const uint32_t StaticEventType
Definition: Event.hpp:10
Transaction(SystemManager &sm)
Definition: SystemManager.hpp:134
std::condition_variable queueCondVar
Definition: SystemManager.hpp:64
TDelta dtime
Definition: SystemManager.hpp:66
std::string EventTypeName
Definition: Event.hpp:13
SystemRemovedEvent(SystemManager &sm, System &s)
Definition: SystemManager.hpp:124
static decltype(lowlink) constexpr lowlinkUndef
Definition: SystemManager.hpp:50
SystemPtrVector systems
Definition: SystemManager.hpp:75
SystemTypeId lowlink
Definition: SystemManager.hpp:47
const EventTypeName getTypeName() const
Definition: SystemManager.hpp:99
std::queue< SystemTypeId > queue
Definition: SystemManager.hpp:62
static decltype(index) constexpr indexUndef
Definition: SystemManager.hpp:49
~Transaction()
Definition: SystemManager.hpp:143
void run(TDelta dtime)
Definition: SystemManager.cpp:277
Definition: SystemManager.hpp:60
Definition: SystemManager.hpp:90
const SystemTypeId system
Definition: SystemManager.hpp:40
std::mutex queueMutex
Definition: SystemManager.hpp:63
Definition: SystemManager.hpp:128
Definition: SystemManager.hpp:39
Transaction transact()
Definition: SystemManager.hpp:170
Definition: SystemManager.hpp:85
SystemManager & sysMan
Definition: SystemManager.hpp:122
SystemTypeId runCount
Definition: SystemManager.hpp:67
void computeSystemOrder()
Definition: SystemManager.cpp:163
SystemManager(World &)
Definition: SystemManager.cpp:268
RunsAfterCreatesLoopException(SystemLoopPath &&slp)
Definition: SystemManager.hpp:91
std::vector< std::unique_ptr< System >> SystemPtrVector
Definition: SystemManager.hpp:36
std::condition_variable runCountCondVar
Definition: SystemManager.hpp:69
std::set< SystemTypeId > successors
Definition: SystemManager.hpp:44
std::map< std::string, System & > systemsByName
Definition: SystemManager.hpp:77
unsigned int counter
Definition: SystemManager.hpp:53
bool exit
Definition: SystemManager.hpp:65
uint32_t EventType
Definition: Event.hpp:11
const char *const StaticEventTypeName
Definition: Event.hpp:12
std::stack< SystemTypeId > SystemLoopPath
Definition: SystemManager.hpp:82
virtual const char * getName() const =0
Definition: SystemManager.hpp:97
SystemPtrVector & systems
Definition: SystemManager.hpp:41
std::vector< std::thread > threads
Definition: SystemManager.hpp:61
Definition: SystemManager.hpp:112
World & w
Definition: SystemManager.hpp:25
std::mutex counterMut
Definition: SystemManager.hpp:54
World & world() const
Definition: SystemManager.hpp:32
Definition: SystemManager.hpp:22
std::vector< std::set< SystemTypeId >> SystemLoopVector
Definition: SystemManager.hpp:83
const EventTypeName getTypeName() const
Definition: SystemManager.hpp:114
SystemManager & sm
Definition: SystemManager.hpp:130