oln::utils::timer Class Reference

#include <timer.hh>

Collaboration diagram for oln::utils::timer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 timer ()
void start ()
float restart ()
void resume ()
float stop ()
float last_time () const
 Time since the last resume() or start().
float total_time () const
 Total time elapsed.

Detailed Description

Timer class.

Definition at line 39 of file timer.hh.


Constructor & Destructor Documentation

oln::utils::timer::timer (  )  [inline]

Constructor.

Note:
The timer is not stopped, it is in a so-called 'unknown state'. Therefor, Restart can not be called.

Definition at line 47 of file timer.hh.

00048       {
00049         status_ = e_unknown;
00050         total_time_ = 0;
00051         start_time_ = clock();
00052       }


Member Function Documentation

void oln::utils::timer::start (  )  [inline]

Start the timer.

Precondition:
The timer should not be running.

Definition at line 59 of file timer.hh.

Referenced by restart().

00060       {
00061         assertion(status_ != e_running);
00062         total_time_ = 0;
00063         stop_time_ = 0;
00064         status_ = e_running;
00065         start_time_ = clock();
00066       }

float oln::utils::timer::restart (  )  [inline]

Restart the timer.

Precondition:
The timer should have been start at least one time.

Definition at line 72 of file timer.hh.

References start(), and total_time().

00073       {
00074         assertion(status_ != e_unknown);
00075         float val = total_time();
00076         status_ = e_stopped;
00077         start();
00078         return val;
00079       }

void oln::utils::timer::resume (  )  [inline]

Resume the timer.

Precondition:
The timer should be stopped.

Definition at line 86 of file timer.hh.

00087       {
00088         assertion(status_ == e_stopped);
00089         status_ = e_running;
00090         start_time_ = clock();
00091       }

float oln::utils::timer::stop (  )  [inline]

Stop the timer.

Precondition:
The timer should be running.

Definition at line 98 of file timer.hh.

References total_time().

00099       {
00100         assertion(status_ == e_running);
00101         stop_time_ = clock();
00102         total_time_ += (stop_time_ - start_time_);
00103         status_ = e_stopped;
00104         return total_time();
00105       }


The documentation for this class was generated from the following file:
Generated on Tue Feb 20 20:30:07 2007 for Olena by  doxygen 1.5.1