Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

timer Class Reference

Class for measuring time. More...

#include <timer.hpp>


Public Member Functions

 timer (void)
void reset (void)
double elapsed (void) const

Protected Attributes

struct timeval time
 Time of construction of this object.


Detailed Description

Class for measuring time.

Definition at line 23 of file timer.hpp.


Constructor & Destructor Documentation

timer::timer ( void   )  [inline]

Constructor starting timer. The constructor will call reset() to.

Definition at line 28 of file timer.hpp.

References reset().

00028 { reset(); }


Member Function Documentation

void timer::reset ( void   )  [inline]

Restart timer. Reset the time elapsed to zero again.

Definition at line 31 of file timer.hpp.

References time.

Referenced by timer().

00031                    {
00032     gettimeofday( &time, NULL );
00033   }

double timer::elapsed ( void   )  const

Get elapsed time. The time elapsed (in seconds) is returned.

Returns:
Time elapsed since last call of timer or reset() .

Definition at line 18 of file timer.cpp.

References time.

Referenced by MySQLSocket::connect().

00019 {
00020   struct timeval actualTime;
00021   gettimeofday( &actualTime, NULL );
00022 
00023   // Use timersub-define, which does overflow-handling.
00024   struct timeval difference;
00025   timersub( &actualTime, &time, &difference );
00026 
00027   return difference.tv_sec + difference.tv_usec * 1.0E-6;
00028 }


Field Documentation

struct timeval timer::time [read, protected]

Time of construction of this object.

Definition at line 40 of file timer.hpp.

Referenced by elapsed(), and reset().


The documentation for this class was generated from the following files:

anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:29 2008 - GNU Free Documentation License