17#ifndef _FGE_C_TIMER_HPP_INCLUDED
18#define _FGE_C_TIMER_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_callback.hpp"
45 explicit Timer(std::chrono::milliseconds
const& goal);
52 Timer(std::chrono::milliseconds
const& goal,
bool paused);
60 Timer(std::chrono::milliseconds
const& goal, std::string name,
bool paused);
186 std::chrono::steady_clock::time_point
const g_lifeTimePoint;
188 std::chrono::milliseconds g_elapsedTime;
189 std::chrono::milliseconds g_goalDuration;
195 mutable std::mutex g_mutex;
This class is used to handle callbacks in a safe way.
Definition C_callback.hpp:189
A timer that can be used with the timer manager to handle time.
Definition C_timer.hpp:35
void setGoalDuration(std::chrono::milliseconds const &t)
Set the goal duration of the timer.
void pause()
Pause the timer.
std::chrono::milliseconds getTimeLeft() const
Get the remaining time of the timer.
void subToGoal(std::chrono::milliseconds const &t)
Subtract an amount of time to the goal duration of the timer.
void restart()
Restart the timer.
fge::CallbackHandler< fge::Timer & > _onTimeReached
The callback called when the timer reaches the goal.
Definition C_timer.hpp:183
std::chrono::milliseconds const & getGoalDuration() const
Get the goal time of the timer.
std::chrono::milliseconds getLifeDuration() const
Get the life time of the timer as milliseconds.
void setName(std::string const &name)
Set the timer name.
void setElapsedTime(std::chrono::milliseconds const &t)
Set the elapsed time of the timer.
void resume()
Unpause the timer.
bool goalReached() const
Check if the goal has been reached.
Timer(std::chrono::milliseconds const &goal)
Create a new timer with the given time goal.
std::string const & getName() const
Get the timer name.
std::chrono::steady_clock::time_point const & getLifeTimePoint() const
Get the life time of the timer.
std::chrono::milliseconds const & getElapsedTime() const
Get the elapsed time of the timer.
void subToElapsedTime(std::chrono::milliseconds const &t)
Subtract an amount of time to the elapsed time of the timer.
Timer(std::chrono::milliseconds const &goal, bool paused)
Create a new timer with the given time goal and pause state.
void addToElapsedTime(std::chrono::milliseconds const &t)
Add an amount of time to the elapsed time of the timer.
void addToGoal(std::chrono::milliseconds const &t)
Add an amount of time to the goal duration of the timer.
bool isPaused() const
Check if the timer is paused.
Timer(std::chrono::milliseconds const &goal, std::string name, bool paused)
Create a new timer with the given time goal, name and pause state.