- worked on about everything - grid walker using plugable modules - wifi models - new distributions - worked on geometric data-structures - added typesafe timestamps - worked on grid-building - added sensor-classes - added sensor analysis (step-detection, turn-detection) - offline data reader - many test-cases
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#ifndef TIMESTAMP_H
|
|
#define TIMESTAMP_H
|
|
|
|
/**
|
|
* helper-class to handle timestamps
|
|
*/
|
|
struct Timestamp {
|
|
|
|
private:
|
|
|
|
/** internal timestamp in milliseconds */
|
|
int64_t _ms;
|
|
|
|
/** HIDDEN ctor. use factory methods */
|
|
explicit Timestamp(const int64_t ms) : _ms(ms) {;}
|
|
|
|
public:
|
|
|
|
/** empty ctor */
|
|
explicit Timestamp() : _ms(0) {;}
|
|
|
|
/** get timestamp from the given value which represents milliesconds */
|
|
static inline Timestamp fromMS(const int64_t ms) {return Timestamp(ms);}
|
|
|
|
/** get timestamp from the given value which represents seconds */
|
|
static inline Timestamp fromSec(const float sec) {return Timestamp(sec*1000);}
|
|
|
|
|
|
public:
|
|
|
|
/** get timestamp in milliseconds */
|
|
inline uint64_t ms() const {return _ms;}
|
|
|
|
/** get timestamp in seconds */
|
|
inline float sec() const {return _ms/1000.0f;}
|
|
|
|
|
|
public:
|
|
|
|
/** is this timestamp zero? */
|
|
bool isZero() const {return _ms == 0;}
|
|
|
|
/** equal? */
|
|
bool operator == (const Timestamp& o) const {return _ms == o._ms;}
|
|
|
|
/** not equal? */
|
|
bool operator != (const Timestamp& o) const {return _ms != o._ms;}
|
|
|
|
/** smaller than the given one? */
|
|
bool operator < (const Timestamp& o) const {return _ms < o._ms;}
|
|
|
|
/** greater than the given one? */
|
|
bool operator > (const Timestamp& o) const {return _ms > o._ms;}
|
|
|
|
|
|
Timestamp operator - (const Timestamp& o) const {return Timestamp(_ms - o._ms);}
|
|
|
|
Timestamp operator + (const Timestamp& o) const {return Timestamp(_ms + o._ms);}
|
|
|
|
/** cast to float */
|
|
operator float () const {return sec();}
|
|
|
|
|
|
};
|
|
|
|
#endif // TIMESTAMP_H
|