Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Ticker.cpp
Go to the documentation of this file.
2#include <stdexcept>
3#include <limits>
4
5namespace EngineCore
6{
7
8Ticker::Ticker(uint32_t amountOfTickables)
9{
10 for (uint32_t index = 0u; index < amountOfTickables; index++)
11 {
12 tickIds.push(index);
13 }
14}
15
16uint32_t Ticker::addTickable(ITickable* tickable)
17{
18 if (!tickable) return std::numeric_limits<uint32_t>::max();
19 if (tickIds.empty()) throw std::runtime_error("Exceeded available tick ids");
20
21 const uint32_t tickId = tickIds.top();
22 tickIds.pop();
23
24 allTickables[tickId] = tickable;
25
26 return tickId;
27}
28
29void Ticker::removeTickable(uint32_t tickId)
30{
31 allTickables.erase(tickId);
32 tickIds.push(tickId);
33}
34void Ticker::tick(double deltaTime)
35{
36
37}
38
39} // namespace EngineCore
This is the interface which is used to call a tick function on an object. Everything which should be ...
Definition Tick.h:10
std::stack< uint32_t > tickIds
Definition Ticker.h:20
void removeTickable(uint32_t tickId)
Definition Ticker.cpp:29
uint32_t addTickable(ITickable *tickable)
Definition Ticker.cpp:16
std::map< uint32_t, ITickable * > allTickables
Definition Ticker.h:21
void tick(double deltaTime)
Definition Ticker.cpp:34
Log category system implementation.