diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-15 16:07:58 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-15 16:07:58 +0000 |
commit | fa589fafa7f094bc1bf07642b55f3d824814adba (patch) | |
tree | dc1b96685c4d92cd838551ee14ce02a7f81eb5bf /src/core/timer.h | |
parent | b780874cf4ab23cf9e48aa23da2394169da24887 (diff) |
moved Timer to core::
Diffstat (limited to 'src/core/timer.h')
-rw-r--r-- | src/core/timer.h | 45 |
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__ + |