KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
invocation.hpp
1/*
2 KTech, Kaup's C++ 2D terminal game engine library.
3 Copyright (C) 2023-2025 Ethan Kaufman (AKA Kaup)
4
5 This file is part of KTech.
6
7 KTech is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 any later version.
11
12 KTech is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with KTech. If not, see <https://www.gnu.org/licenses/>.
19*/
20
21#include "time.hpp"
22#include "../engine.hpp"
23
68{
70 std::function<bool()> m_callback;
71 bool m_active = false;
72 long m_timePassed = 0;
73 long m_duration = 0;
74
75 Invocation(Engine& engine, const std::function<bool()>& callback);
77
78 void Invoke(long time, Measurement measurement);
79 void Cancel();
80};
Complete engine containing all engine components.
Definition engine.hpp:41
Measurement
Time measurement.
Definition time.hpp:39
Calls a function after a given time.
Definition invocation.hpp:68
Engine & engine
Parent Engine.
Definition invocation.hpp:69
long m_timePassed
How much time (in microseconds) actually passed since invocation started until now (if active),...
Definition invocation.hpp:72
void Invoke(long time, Measurement measurement)
Invoke your callback function.
Definition invocation.cpp:82
void Cancel()
Cancel the current invocation.
Definition invocation.cpp:92
~Invocation()
Safely deregister invocation from Time.
Definition invocation.cpp:40
std::function< bool()> m_callback
Function to invoke.
Definition invocation.hpp:70
bool m_active
Whether currently invoked (true: invoked, false: stationary).
Definition invocation.hpp:71
long m_duration
How much time (in microseconds) should pass before your function gets called (if active),...
Definition invocation.hpp:73