Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Timer Class Reference

#include <timer.hh>

Inheritance diagram for Timer:

Public Member Functions

 Timer (const Timer &t)
 
 Timer (long int seconds, long int useconds)
 
 Timer ()
 
bool hasExpired () const
 
bool hasExpiredWrt (Timer const &t) const
 
void set (long int seconds, long int useconds)
 
void set (const Timer &t)
 

Detailed Description

Author
cpellegrino

Definition at line 10 of file timer.hh.

Constructor & Destructor Documentation

Timer::Timer ( const Timer t)
inline

Definition at line 15 of file timer.hh.

16  {
17  set(t);
18  }
void set(long int seconds, long int useconds)
Definition: timer.cc:27
Timer::Timer ( long int  seconds,
long int  useconds 
)
inline

Definition at line 20 of file timer.hh.

21  {
22  set(seconds, useconds);
23  }
void set(long int seconds, long int useconds)
Definition: timer.cc:27
Timer::Timer ( )
inline

Definition at line 26 of file timer.hh.

27  {}

Member Function Documentation

bool Timer::hasExpired ( ) const

Definition at line 21 of file timer.cc.

22 {
23  Timer const t(0, 0);
24  return Timer::hasExpiredWrt(t);
25 }
bool hasExpiredWrt(Timer const &t) const
Definition: timer.cc:7
Definition: timer.hh:10
bool Timer::hasExpiredWrt ( Timer const &  t) const
Author
cpellegrino

Definition at line 7 of file timer.cc.

8 {
9  if (t.tv_sec > tv_sec)
10  return true;
11 
12  if (t.tv_sec < tv_sec)
13  return false;
14 
15  if (t.tv_usec > tv_usec)
16  return true;
17 
18  return false;
19 }
void Timer::set ( long int  seconds,
long int  useconds 
)

Definition at line 27 of file timer.cc.

28 {
29  static const int usec_in_a_sec = 1000000;
30 
31  gettimeofday(this, 0);
32 
33  tv_sec += seconds;
34  tv_usec += useconds;
35  tv_sec += (tv_usec) / usec_in_a_sec;
36  tv_usec %= usec_in_a_sec;
37 }
void Timer::set ( const Timer t)
inline

Definition at line 36 of file timer.hh.

37  {
38  tv_sec = t.tv_sec;
39  tv_usec = t.tv_usec;
40  }

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