diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/VirtualClock.h	Sat Sep 12 20:05:55 2015 +0100
@@ -0,0 +1,39 @@
+#ifndef VIRTUAL_CLOCK_H_INCLUDED
+#define VIRTUAL_CLOCK_H_INCLUDED
+
+#include "stats.hpp"
+#include "Clock.h"
+
+class VirtualClock{
+private:
+	myClock_t startTime;
+	myClock_t lastSync;
+	bool firstRun;
+	double period;
+	MovingAverage<double> movingAverage;
+public:
+	void init();
+	VirtualClock();
+/**
+	Call this method at regular intervals to sync che virtual clock
+*/
+	void sync();
+/**
+	Call this method asynchronously, passing a number of equally spaced events that have elapsed since the last call.
+*/
+	void sync(double count);
+/**
+	Get the current time according to the VirtualClock.
+	
+	@return Time elapsed since the first call to sync(), in period units. 
+*/
+	double getNow();
+/** 
+	Get the length of the period.
+	
+	Get the length of the period (difference between calls to sync() after various filtering operations)
+*/
+	double getPeriod();
+};
+
+#endif /* VIRTUAL_CLOCK_H_INCLUDED */