Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-15 16:07:58 +0000
committerStijn Buys <ingar@osirion.org>2008-08-15 16:07:58 +0000
commitfa589fafa7f094bc1bf07642b55f3d824814adba (patch)
treedc1b96685c4d92cd838551ee14ce02a7f81eb5bf /src/core/timer.h
parentb780874cf4ab23cf9e48aa23da2394169da24887 (diff)
moved Timer to core::
Diffstat (limited to 'src/core/timer.h')
-rw-r--r--src/core/timer.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/core/timer.h b/src/core/timer.h
new file mode 100644
index 0000000..9e172bf
--- /dev/null
+++ b/src/core/timer.h
@@ -0,0 +1,45 @@
+/*
+ core/timer.h
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CORE_TIMER_H__
+#define __INCLUDED_CORE_TIMER_H__
+
+#include <sys/time.h>
+
+namespace core {
+
+/// a timer measures intervals in seconds
+/*! A timer class measures the time elapsed
+* between the last two calls to its mark() function.
+*/
+class Timer {
+public:
+ /// Constructor
+ Timer();
+ /// Destructor
+ ~Timer();
+
+ /// mark the current time as zero
+ /*! Reset the timer, all subsequent calls too elapsed() will
+ * use the current timestamp as reference
+ */
+ void mark();
+
+ /*! return the time elapsed since the last mark
+ * @see mark()
+ */
+ float elapsed();
+
+private:
+ float timer_elapsed;
+ struct timezone timer_tz;
+ struct timeval timer_tick;
+}; // class Timer
+
+} // namespace core
+
+#endif // __INCLUDED_CORE_TIMER_H__
+