MonotonicTime Class Reference

This class stores samples of the ever-increasing system ticker (the "monotonic clock" in Archy speak) and stores them. The samples can then be manipulated by member functions. More...

#include <monotime.h>

List of all members.

Public Member Functions

 MonotonicTime ()
 MonotonicTime class constructor Create an instance of the time class by taking a sample of MonotonicTime.
 MonotonicTime (UINT32)
 MonotonicTime class constructor Create an instance of the time class by setting it to the specified time.
UINT32 Sample ()
 Take a sample of "now" in monotonic time.
BOOL Elapsed (UINT32)
 Test whether the given time interval has elapsed since the monotonic time was last sampled.
BOOL Elapsed (UINT32, BOOL)
 Test whether the given time interval has elapsed since the monotonic time was last sampled. If the update flag is set then the sample time is reset to be the EXACT time when the interval was exceeded. This allows the interval to be regular and accurate in the long-term even though individual intervals will be subject to timing and sampling innaccuracies.
 operator UINT32 ()
 Cast operator that allows comparisons of MonotonicTime objects to be made.

Static Public Member Functions

static void Init ()
 MonotonicTime initialiser.

Private Attributes

UINT32 SampleTime

Static Private Attributes

static wxStopWatch s_stopwatch


Detailed Description

This class stores samples of the ever-increasing system ticker (the "monotonic clock" in Archy speak) and stores them. The samples can then be manipulated by member functions.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/1993 Base Class: None Friends: None
Where times are passed in and out of these functions they are always given in milliseconds.

Definition at line 131 of file monotime.h.


Constructor & Destructor Documentation

MonotonicTime::MonotonicTime  ) 
 

MonotonicTime class constructor Create an instance of the time class by taking a sample of MonotonicTime.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

Definition at line 164 of file monotime.cpp.

00165 {
00166     Sample();
00167 }

MonotonicTime::MonotonicTime UINT32  initialiser  ) 
 

MonotonicTime class constructor Create an instance of the time class by setting it to the specified time.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

Definition at line 192 of file monotime.cpp.

00193 {
00194     SampleTime = initialiser;
00195 }


Member Function Documentation

BOOL MonotonicTime::Elapsed UINT32  interval,
BOOL  update
 

Test whether the given time interval has elapsed since the monotonic time was last sampled. If the update flag is set then the sample time is reset to be the EXACT time when the interval was exceeded. This allows the interval to be regular and accurate in the long-term even though individual intervals will be subject to timing and sampling innaccuracies.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
Flag saying whether interval has elapsed or not

Errors: None

Definition at line 297 of file monotime.cpp.

00298 {
00299     if ( Elapsed( interval ) )
00300     {
00301 //#if defined(__WXGTK__)
00302 //      interval = interval * CLOCKS_PER_SEC / 1000;
00303 //#endif        
00304 
00305         if ( update )
00306             SampleTime += interval;
00307 
00308         return TRUE;
00309     }
00310     return FALSE;
00311 }

BOOL MonotonicTime::Elapsed UINT32  interval  ) 
 

Test whether the given time interval has elapsed since the monotonic time was last sampled.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
Flag saying whether interval has elapsed or not

Errors: None

Definition at line 258 of file monotime.cpp.

00259 {
00260 #if defined(__WXMSW__)
00261     return ( ( SampleTime + interval ) < GetTickCount() );
00262 #elif defined(__WXGTK__) || defined(__WXMAC__)
00263 //  return( ( SampleTime + ( interval * CLOCKS_PER_SEC / 1000 ) ) < (UINT32)clock() );
00264 //  return ( ( SampleTime + interval ) < GetPosixTickCount() );
00265     return ((SampleTime +interval) < (UINT32)s_stopwatch.Time());
00266 #else
00267     #pragma error( "Not impl'ed from this architechure" );
00268 #endif
00269 }

void MonotonicTime::Init void   )  [static]
 

MonotonicTime initialiser.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/02/2006
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

Definition at line 135 of file monotime.cpp.

00136 {
00137     s_stopwatch.Start();
00138 }

MonotonicTime::operator UINT32  ) 
 

Cast operator that allows comparisons of MonotonicTime objects to be made.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/12/95
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
The monotonic time expressed as a UINT32

Errors: None

Definition at line 327 of file monotime.cpp.

00328 {
00329     return SampleTime;
00330 }

UINT32 MonotonicTime::Sample  ) 
 

Take a sample of "now" in monotonic time.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
The Sampled time

Errors: None

Definition at line 220 of file monotime.cpp.

00221 {
00222 #if defined(__WXMSW__)
00223     SampleTime = GetTickCount();
00224 #elif defined(__WXGTK__) || defined(__WXMAC__)
00225 //  SampleTime = count();
00226 //  SampleTime = GetPosixTickCount();
00227     SampleTime = s_stopwatch.Time();
00228 #else
00229     #pragma error( "Not impl'ed from this architechure" );
00230 #endif
00231 
00232     return SampleTime;
00233 }


Member Data Documentation

wxStopWatch MonotonicTime::s_stopwatch [static, private]
 

Definition at line 149 of file monotime.h.

UINT32 MonotonicTime::SampleTime [private]
 

Definition at line 147 of file monotime.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:16 2007 for Camelot by  doxygen 1.4.4