SDLU/include/structures/Clock.hpp

43 lines
764 B
C++
Raw Normal View History

2021-04-24 00:01:36 +00:00
/*****************************************************************//**
* @file Clock.hpp
* @brief A small timing utility
*
* @author Lauchmelder
* @date April 2021
*********************************************************************/
2021-04-23 23:21:15 +00:00
#pragma once
#include "Util.hpp"
#include "Time.hpp"
SDLU_BEGIN
2021-04-24 00:01:36 +00:00
/**
* @brief Essentially a timer.
*/
2021-04-23 23:21:15 +00:00
class Clock
{
public:
2021-04-24 00:01:36 +00:00
/**
* @brief Creates a new Clock. It has not yet been started, call Restart() before doing anything else.
*/
2021-04-23 23:21:15 +00:00
Clock();
2021-04-24 00:01:36 +00:00
/**
* @brief Returns the time elapsed since the last Restart() call.
*/
2021-04-23 23:21:15 +00:00
Time GetElapsedTime();
2021-04-24 00:01:36 +00:00
/**
* @brief Restarts the Clock.
*
* @return The time elapsed since the last Restart() call.
*/
2021-04-23 23:21:15 +00:00
Time Restart();
private:
Time lastTime;
};
SDLU_END