annotate include/VirtualClock.h @ 135:e77e2e712fbc ClockSync

To work with the ClockSync plugin
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 12 Sep 2015 20:05:55 +0100
parents
children 44d07fa9bd03
rev   line source
giuliomoro@135 1 #ifndef VIRTUAL_CLOCK_H_INCLUDED
giuliomoro@135 2 #define VIRTUAL_CLOCK_H_INCLUDED
giuliomoro@135 3
giuliomoro@135 4 #include "stats.hpp"
giuliomoro@135 5 #include "Clock.h"
giuliomoro@135 6
giuliomoro@135 7 class VirtualClock{
giuliomoro@135 8 private:
giuliomoro@135 9 myClock_t startTime;
giuliomoro@135 10 myClock_t lastSync;
giuliomoro@135 11 bool firstRun;
giuliomoro@135 12 double period;
giuliomoro@135 13 MovingAverage<double> movingAverage;
giuliomoro@135 14 public:
giuliomoro@135 15 void init();
giuliomoro@135 16 VirtualClock();
giuliomoro@135 17 /**
giuliomoro@135 18 Call this method at regular intervals to sync che virtual clock
giuliomoro@135 19 */
giuliomoro@135 20 void sync();
giuliomoro@135 21 /**
giuliomoro@135 22 Call this method asynchronously, passing a number of equally spaced events that have elapsed since the last call.
giuliomoro@135 23 */
giuliomoro@135 24 void sync(double count);
giuliomoro@135 25 /**
giuliomoro@135 26 Get the current time according to the VirtualClock.
giuliomoro@135 27
giuliomoro@135 28 @return Time elapsed since the first call to sync(), in period units.
giuliomoro@135 29 */
giuliomoro@135 30 double getNow();
giuliomoro@135 31 /**
giuliomoro@135 32 Get the length of the period.
giuliomoro@135 33
giuliomoro@135 34 Get the length of the period (difference between calls to sync() after various filtering operations)
giuliomoro@135 35 */
giuliomoro@135 36 double getPeriod();
giuliomoro@135 37 };
giuliomoro@135 38
giuliomoro@135 39 #endif /* VIRTUAL_CLOCK_H_INCLUDED */