ANNA Suite  2020b
Multipurpose development suite for Telco applications
CounterScope.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_core_oam_CounterScope_hpp
10 #define anna_core_oam_CounterScope_hpp
11 
12 #include <anna/core/functions.hpp>
14 #include <anna/core/mt/Mutex.hpp>
15 
17 
18 namespace anna {
19 
20 class Guard;
21 
22 namespace xml {
23 class Node;
24 }
25 
26 namespace oam {
27 
28 
32 class CounterScope : public Mutex {
33 public:
34 
35  static const int MaxCounter = 1000;
40  ~CounterScope();
41 
47  const std::string& getName() const { return a_name; }
48 
53  const int getId() const { return a_id; }
54 
60  void create(const int counter, const char* name) noexcept(false);
61 
66  std::string asString() const ;
67 
72  xml::Node* asXML(xml::Node* parent) const noexcept(false);
73 
74 protected:
81  Counter::type_t increment(const int counter, const Counter::type_t value) noexcept(false);
82 
89  Counter::type_t assign(const int counter, const Counter::type_t value) noexcept(false);
90 
95  Counter::type_t getValue(const int counter) const noexcept(false);
96 
101  const Counter* getCounter(const int counter) const noexcept(false);
102 
103 public:
104 
109  U64 getAccValue(const int counter) const noexcept(false);
110 
115  int resetAccValues() noexcept(false);
116 
117 private:
118  const int a_id;
119  const std::string a_name;
120  Counter* a_counters [MaxCounter];
121 
122  CounterScope(const int id, const char* name) :
124  a_id(id),
125  a_name(name) {
126  anna_memset(a_counters, 0, sizeof(a_counters));
127  }
128 
129  friend class Safe;
130  friend class Handler;
131  friend class Module;
132 };
133 
134 }
135 }
136 
137 #endif
138 
Definition: Handler.hpp:33
const std::string & getName() const
Definition: CounterScope.hpp:47
Definition: Module.hpp:135
Definition: Node.hpp:56
#define anna_memset(a, b, c)
Definition: defines.hpp:43
Definition: Mutex.hpp:43
Definition: Counter.hpp:25
unsigned int type_t
Definition: Counter.hpp:27
Definition: CounterScope.hpp:32
xml::Node Node
Definition: Node.hpp:21
const int getId() const
Definition: CounterScope.hpp:53
Definition: app.hpp:12
uint64_t U64
Definition: defines.hpp:81
Definition: Safe.hpp:23
Definition: Mutex.hpp:41