1 
2 /* Web Polygraph       http://www.web-polygraph.org/
3  * Copyright 2003-2011 The Measurement Factory
4  * Licensed under the Apache License, Version 2.0 */
5 
6 #ifndef POLYGRAPH__XSTD_CLOCK_H
7 #define POLYGRAPH__XSTD_CLOCK_H
8 
9 #include "xstd/Time.h"
10 
11 // an object that can show current time and responds to time changes
12 // clocks are syncronized via Clock::Update() call
13 
14 class Clock {
15 	public:
16 		static void Update(bool advanceAll = true);
17 		static Time TheStartTime;
18 
19 	public:
20 		Clock();
21 		virtual ~Clock();
22 
time()23 		Time time() const { return theCurTime; }
Time()24 		operator Time() const { return theCurTime; }
runTime()25 		Time runTime() const { return theCurTime - TheStartTime; }
26 
now()27 		Time now() { update(Time::Now()); return theCurTime; }
28 		virtual void update(Time aCurTime);
29 
30 	protected:
31 		Time theCurTime;
32 };
33 
34 // "Wall clock" or "official clock" (it is always advanced by UpdateClocks())
35 extern Clock &TheClock;
36 
37 #endif
38