Index: src/libchcore/TSpeedTracker.h =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -ra4635addad389b9e117679437a3e1b64a739ea96 --- src/libchcore/TSpeedTracker.h (.../TSpeedTracker.h) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSpeedTracker.h (.../TSpeedTracker.h) (revision a4635addad389b9e117679437a3e1b64a739ea96) @@ -1,52 +1,52 @@ -#ifndef __TSPEEDTRACKER_H__ -#define __TSPEEDTRACKER_H__ - -#include "TString.h" - -namespace chcore -{ - class TSpeedTracker - { - public: - TSpeedTracker(unsigned long long ullTrackTime, unsigned long long ullSampleTime); - - void AddSample(unsigned long long ullValue, unsigned long long ullTimestamp); - void Clear(); - - // retrieves speed per second - double GetSpeed() const; - - TString ToString() const; - void FromString(const TString& strData); - - private: - TSpeedTracker(const TSpeedTracker&); - TSpeedTracker& operator=(const TSpeedTracker&); - - static double NormalizeValueByTime(unsigned long long ullValue, unsigned long long ullTime, unsigned long long ullNormalizeTime = 1000); - - size_t GetNextSampleIndexAndIncrease(); - void FinalizeIncompleteSample(double dSpeed, unsigned long long& ullInterval); - void AddCompleteSamples(double dSpeed, unsigned long long& ullInterval); - void PrepareIncompleteSample(unsigned long long ullInterval, double dSpeed); - double CalculateIncompleteSampleNormalizedSpeed() const; - - private: - // initialized in constructor (does not change throughout the whole lifetime) - const size_t m_stRequiredSamples; // how many samples of m_ullSampleTime do we want to keep? - const unsigned long long m_ullSampleTime; // interval covered by a single sample - const double m_dSamplesPerSecond; // how many samples fit in one second - - // vector of samples with pointer to the next element to be filled - std::vector m_vSamples; // speed per sample - size_t m_stNextSamplePos; // points to the element with the oldest sample - - unsigned long long m_ullLastTimestamp; // last time some sample was processed - - double m_dPartialSpeedNotInSamples; // specifies count of data processed in the m_ullTimeIntervalNotInSamples interval - unsigned long long m_ullTimeIntervalNotInSamples; // interval that was not enough to add m_ullDataNotInSamples to samples - unsigned long long m_ullZeroIntervalData; - }; -} - -#endif +#ifndef __TSPEEDTRACKER_H__ +#define __TSPEEDTRACKER_H__ + +#include "TString.h" + +namespace chcore +{ + class TSpeedTracker + { + public: + TSpeedTracker(unsigned long long ullTrackTime, unsigned long long ullSampleTime); + + void AddSample(unsigned long long ullValue, unsigned long long ullTimestamp); + void Clear(); + + // retrieves speed per second + double GetSpeed() const; + + TString ToString() const; + void FromString(const TString& strData); + + private: + TSpeedTracker(const TSpeedTracker&); + TSpeedTracker& operator=(const TSpeedTracker&); + + static double NormalizeValueByTime(unsigned long long ullValue, unsigned long long ullTime, unsigned long long ullNormalizeTime = 1000); + + size_t GetNextSampleIndexAndIncrease(); + void FinalizeIncompleteSample(double dSpeed, unsigned long long& ullInterval); + void AddCompleteSamples(double dSpeed, unsigned long long& ullInterval); + void PrepareIncompleteSample(unsigned long long ullInterval, double dSpeed); + double CalculateIncompleteSampleNormalizedSpeed() const; + + private: + // initialized in constructor (does not change throughout the whole lifetime) + const size_t m_stRequiredSamples; // how many samples of m_ullSampleTime do we want to keep? + const unsigned long long m_ullSampleTime; // interval covered by a single sample + const double m_dSamplesPerSecond; // how many samples fit in one second + + // vector of samples with pointer to the next element to be filled + std::vector m_vSamples; // speed per sample + size_t m_stNextSamplePos; // points to the element with the oldest sample + + unsigned long long m_ullLastTimestamp; // last time some sample was processed + + double m_dPartialSpeedNotInSamples; // specifies count of data processed in the m_ullTimeIntervalNotInSamples interval + unsigned long long m_ullTimeIntervalNotInSamples; // interval that was not enough to add m_ullDataNotInSamples to samples + unsigned long long m_ullZeroIntervalData; + }; +} + +#endif