summaryrefslogtreecommitdiff
path: root/src/time_utils.hpp
blob: f8f2eb3f9131c6fade414afdac2e460f480d7288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef TIME_UTILS_HPP
#define TIME_UTILS_HPP

/**
 * A representation of time.
 */
class Time
{
public:
	/**
	 * A representation of time.
	 *
	 * @param time_micros Time in microseconds
	 */
	Time(unsigned long time_micros);

	/**
	 * Updates the time to the current time.
	 */
	void update();

	/**
	 * Returns the difference between two points in time.
	 *
	 * @param prev_time A previous point in time
	 */
	Time diff(Time prev_time);

	/**
	 * Returns the time in seconds.
	 */
	float secs();

	/**
	 * Returns the time in milliseconds.
	 */
	unsigned long millisecs();

	/**
	 * Returns the time in microseconds.
	 */
	unsigned long microsecs();

private:
	unsigned long _time_micros;
};

/**
 * Returns a time object for the time since the program started.
 */
Time time_now();

#endif