ANNA Suite  2020b
Multipurpose development suite for Telco applications
ApplicationMessageOamModule.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_diameter_comm_ApplicationMessageOamModule_hpp
10 #define anna_diameter_comm_ApplicationMessageOamModule_hpp
11 
12 
13 // Project
14 #include <anna/core/mt/Mutex.hpp>
15 #include <anna/core/Singleton.hpp>
17 #include <anna/core/oam/Module.hpp>
18 
19 // Standard
20 #include <string>
21 #include <map>
22 
23 namespace anna {
24 
25 namespace diameter {
26 
27 namespace comm {
28 
29 
105 class ApplicationMessageOamModule : public anna::oam::Module, public anna::Singleton <ApplicationMessageOamModule> {
106 
107  std::map<std::string /* event id */, int /* base offset */> a_eventMap;
108  std::map<unsigned int /* stack id */, int /* scope id */> a_stackMap;
109 
110  int a_counter_types;
111 
112  anna::Mutex a_mutex; // counter scope switch
113 
114 public:
115 
116  struct Counter {
117  enum _v
118  {
119  None = -1,
120 
128 
136  };
137 
139  };
140 
141  /* virtual */std::string getDefaultInternalCounterDescription(const int & counterType) const { return Counter::asCString((Counter::_v)counterType); }
142 
143  // map stack id with a scope id
144  void createStackCounterScope(int /* scope id */, unsigned int /* stack id */) noexcept(false);
145 
146  // translate message code into offset and invoke parent class count method. The message applicationId will be used as stack id
147  // resultCode shall be -1 for non-answers
148  void count (int messageCode, int resultCode, unsigned int stackId, const int & type, const int & amount = 1) noexcept(false);
149 
150  // Number of different counter types for each message
151  int getCounterTypes() const { return a_counter_types; }
152 
153  // -1 if multistack
154  int monoStackScopeId() const {
155  return ((a_stackMap.size() != 1) ? -1 : a_stackMap.begin()->second);
156  }
157 
158 private:
159 
160  // private constructor
161  ApplicationMessageOamModule() : anna::oam::Module("Application Message Comm OAM Events") { a_counter_types = Counter::calculateSize(); }
162 
163 
165 };
166 
167 }
168 }
169 }
170 
171 #endif
172 
void createStackCounterScope(int, unsigned int) noexcept(false)
_v
Definition: ApplicationMessageOamModule.hpp:117
Definition: Module.hpp:135
Definition: Singleton.hpp:76
int monoStackScopeId() const
Definition: ApplicationMessageOamModule.hpp:154
std::string getDefaultInternalCounterDescription(const int &counterType) const
Definition: ApplicationMessageOamModule.hpp:141
int getCounterTypes() const
Definition: ApplicationMessageOamModule.hpp:151
Definition: app.hpp:12
Definition: ApplicationMessageOamModule.hpp:119
Definition: Mutex.hpp:41
Definition: ApplicationMessageOamModule.hpp:116
void count(int messageCode, int resultCode, unsigned int stackId, const int &type, const int &amount=1) noexcept(false)
Definition: ApplicationMessageOamModule.hpp:105