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

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         start();
00077         return val;
00078       }

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

Resume the timer.

Precondition:
The timer should be running.

Definition at line 85 of file timer.hh.

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

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::stop  )  [inline]
 

Stop the timer.

Precondition:
The timer should be running.

Definition at line 97 of file timer.hh.

References total_time().

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


The documentation for this class was generated from the following file:
Generated on Thu Apr 15 20:17:27 2004 for Olena by doxygen 1.3.6-20040222