Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

vlClock Class Reference

This class provides a clock for OpenVL. More...

#include <vlclock.h>

List of all members.

Public Member Functions

 vlClock (bool start=false)
 Default constructor.

 ~vlClock ()
 Default destructor.

void start ()
 Start the clock.

double stop ()
 Stop the clock.

void restart ()
 Restarts the clock. Starts counting from zero again.

double get () const
 Get total time for which the clock was active ( time between starts and stops ).

double getStepTime () const
 Get time since the most recent call to start() in seconds.


Private Attributes

timeval m_stepStartTime
 stores time when the timer was started (start() was called)

timeval m_endTime
 stores time when the timer step was stopped

timezone m_timezone
 Needed for call to gettimeofday.

double m_value
 Time in milliseconds.

double m_stepValue
 Time in milliseconds.

bool m_running
 Clock is on or off.


Friends

ostream & operator<< (ostream &os, vlClock const &clock)
 overriding << to enable writing time to a stream


Detailed Description

It gives timings with an accuracy of microseconds.

Todo:
Add function overloading for << and get rid of dozen prints
Author:
Sarang Lakare <sarang@users.sf.net>

Definition at line 43 of file vlclock.h.


Constructor & Destructor Documentation

vlClock::vlClock bool  start = false  ) 
 

Parameters:
enable To start the clock with the constructor, pass true as argument

Definition at line 34 of file vlclock.cpp.

References m_stepStartTime, m_timezone, and start().

vlClock::~vlClock  ) 
 

Definition at line 47 of file vlclock.cpp.


Member Function Documentation

double vlClock::get  )  const
 

NOTE :- This function does not stop the clock if its running.

Definition at line 92 of file vlclock.cpp.

References m_running, m_stepStartTime, and m_value.

double vlClock::getStepTime  )  const
 

If the clock is not running, then it'll give the time for which the clock was running in the latest call to start and stop. NOTE :- This function does not stop the clock if its running.

Definition at line 111 of file vlclock.cpp.

References m_running, m_stepStartTime, and m_stepValue.

Referenced by main().

void vlClock::restart  ) 
 

Definition at line 80 of file vlclock.cpp.

References m_running, m_stepStartTime, m_stepValue, m_timezone, and m_value.

void vlClock::start  ) 
 

If the clock is already running, step clock will be re-started.

Definition at line 57 of file vlclock.cpp.

References m_running, m_stepStartTime, and m_timezone.

Referenced by main(), and vlClock().

double vlClock::stop  ) 
 

Definition at line 68 of file vlclock.cpp.

References m_endTime, m_running, m_stepStartTime, m_stepValue, m_timezone, and m_value.


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
vlClock const &  clock
[friend]
 

Definition at line 67 of file vlclock.h.


Member Data Documentation

struct timeval vlClock::m_endTime [private]
 

Definition at line 76 of file vlclock.h.

Referenced by stop().

bool vlClock::m_running [private]
 

Definition at line 85 of file vlclock.h.

Referenced by get(), getStepTime(), restart(), start(), and stop().

struct timeval vlClock::m_stepStartTime [private]
 

Definition at line 73 of file vlclock.h.

Referenced by get(), getStepTime(), restart(), start(), stop(), and vlClock().

double vlClock::m_stepValue [private]
 

Definition at line 82 of file vlclock.h.

Referenced by getStepTime(), restart(), and stop().

struct timezone vlClock::m_timezone [private]
 

Definition at line 79 of file vlclock.h.

Referenced by restart(), start(), stop(), and vlClock().

double vlClock::m_value [private]
 

Definition at line 82 of file vlclock.h.

Referenced by get(), restart(), and stop().


The documentation for this class was generated from the following files:
Generated on Fri Mar 18 11:33:18 2005 for OpenVL by doxygen 1.3.3