ANNA Suite  2020b
Multipurpose development suite for Telco applications
MicroMeter.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_timex_MicroMeter_hpp
10 #define anna_timex_MicroMeter_hpp
11 
12 #include <anna/core/functions.hpp>
13 
14 namespace anna {
15 
16 namespace timex {
17 
41 class MicroMeter {
42 public:
47  MicroMeter() { a_timestamp = functions::microsecond(); a_topReference = (Microsecond)0; }
48 
54  MicroMeter(const MicroMeter& other) : a_timestamp(other.a_timestamp) { a_topReference = (Microsecond)0; ;}
55 
64  Microsecond result = (now > a_timestamp) ? (now - a_timestamp) : (Microsecond)0;
65  a_timestamp = now;
67  return result;
68  }
69 
82  void setTopReference(const Microsecond & topReference) { a_topReference = topReference; }
83 
87  void clearTopReference() { a_topReference = (Microsecond)0; }
88 
98  Microsecond now = (a_topReference == 0) ? functions::microsecond() : a_topReference;
99  return (now > a_timestamp) ? (now - a_timestamp) : (Microsecond)0;
100  }
101 
108  MicroMeter& operator= (const Microsecond & timestamp) { a_timestamp = timestamp; a_topReference = (Microsecond)0; return *this; }
109 
114  MicroMeter& operator= (const MicroMeter& other) { a_timestamp = other.a_timestamp; a_topReference = other.a_topReference; return *this; }
115 
116 private:
117  Microsecond a_topReference;
118  Microsecond a_timestamp;
119 };
120 
121 }
122 }
123 
124 #endif
125 
126 
MicroMeter(const MicroMeter &other)
Definition: MicroMeter.hpp:54
Microsecond getDelay() const
Definition: MicroMeter.hpp:97
Definition: MicroMeter.hpp:41
MicroMeter & operator=(const Microsecond &timestamp)
Definition: MicroMeter.hpp:108
MicroMeter()
Definition: MicroMeter.hpp:47
Microsecond setControlPoint()
Definition: MicroMeter.hpp:62
void clearTopReference()
Definition: MicroMeter.hpp:87
void setTopReference(const Microsecond &topReference)
Definition: MicroMeter.hpp:82
static Microsecond microsecond()
Definition: functions.hpp:368
Definition: app.hpp:12
Definition: Microsecond.hpp:22