ANNA Suite  2020b
Multipurpose development suite for Telco applications
Meter.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_Meter_hpp
10 #define anna_timex_Meter_hpp
11 
12 #include <anna/core/functions.hpp>
13 
14 namespace anna {
15 
16 namespace timex {
17 
41 class Meter {
42 public:
47  Meter() { a_timestamp = functions::millisecond(); a_topReference = 0; }
48 
54  Meter(const Meter& other) : a_timestamp(other.a_timestamp) { a_topReference = 0; ;}
55 
64  Millisecond result = (now > a_timestamp) ? (now - a_timestamp) : (Millisecond)0;
65  a_timestamp = now;
67  return result;
68  }
69 
83  void setTopReference(const Millisecond & topReference) { a_topReference = topReference; }
84 
88  void clearTopReference() { a_topReference = 0; }
89 
99  Millisecond now = (a_topReference == 0) ? functions::millisecond() : a_topReference;
100  return (now > a_timestamp) ? (now - a_timestamp) : (Millisecond)0;
101  }
102 
109  Meter& operator= (const Millisecond & timestamp) { a_timestamp = timestamp; a_topReference = 0; return *this; }
110 
115  Meter& operator= (const Meter& other) { a_timestamp = other.a_timestamp; a_topReference = other.a_topReference; return *this; }
116 
117 private:
118  Millisecond a_topReference;
119  Millisecond a_timestamp;
120 };
121 
122 }
123 }
124 
125 #endif
126 
127 
void clearTopReference()
Definition: Meter.hpp:88
Definition: Millisecond.hpp:24
Meter & operator=(const Millisecond &timestamp)
Definition: Meter.hpp:109
Meter(const Meter &other)
Definition: Meter.hpp:54
Millisecond getDelay() const
Definition: Meter.hpp:98
Meter()
Definition: Meter.hpp:47
static Millisecond millisecond()
Definition: functions.hpp:379
Millisecond setControlPoint()
Definition: Meter.hpp:62
Definition: app.hpp:12
void setTopReference(const Millisecond &topReference)
Definition: Meter.hpp:83
Definition: Meter.hpp:41