summaryrefslogtreecommitdiff
path: root/src/utils/time.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-14 10:11:32 +0100
committerHampusM <hampus@hampusmat.com>2022-02-14 10:11:32 +0100
commit7892ef9d248c189be68ce7faf63230ec0a318b67 (patch)
tree7c3d07779d5ce96994f81c0cc22e8b667601ee9d /src/utils/time.hpp
parenta03dfe959fcafd238119bdf7f27c07b92064496e (diff)
refactor: reorganize & add debugging
Diffstat (limited to 'src/utils/time.hpp')
-rw-r--r--src/utils/time.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/utils/time.hpp b/src/utils/time.hpp
new file mode 100644
index 0000000..e0385ef
--- /dev/null
+++ b/src/utils/time.hpp
@@ -0,0 +1,53 @@
+#ifndef TIME_HPP
+#define TIME_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