ANNA Suite  2020b
Multipurpose development suite for Telco applications
Engine.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_stack_Engine_hpp
10 #define anna_diameter_stack_Engine_hpp
11 
12 
13 // Local
15 
16 #include <anna/xml/DTDMemory.hpp>
18 #include <anna/core/Singleton.hpp>
19 
20 // STL
21 #include <string>
22 #include <vector>
23 
24 
25 namespace anna {
26 
27 namespace diameter {
28 
29 namespace stack {
30 
31 
32 
33 //------------------------------------------------------------------------------
34 //----------------------------------------------------------------- class Engine
35 //------------------------------------------------------------------------------
39 class Engine : public anna::Singleton <Engine> {
40 
41 
42  const anna::xml::DTDMemory * getDictionariesDTD() const { return &a_dtd; }
43 
44 public:
45 
46  typedef std::map<unsigned int, Dictionary*> stack_container;
47  typedef stack_container::const_iterator const_stack_iterator;
48  typedef stack_container::iterator stack_iterator;
49 
50 
51  // get
59  const Dictionary * getDictionary(unsigned int stackId) const ;
60 
62  const_stack_iterator stack_begin() const { return a_stacks.begin(); }
64  const_stack_iterator stack_end() const { return a_stacks.end(); }
66  int stack_size() const { return a_stacks.size(); }
67 
68  // helpers
74  bool isEmpty(void) const { return (!a_stacks.size()); }
75 
83  std::string asString(bool all = true) const ;
84 
85  // set
86 
120  Dictionary * createDictionary(unsigned int stackId, const std::string & xmlPathFile = "") noexcept(false);
121 
131  Dictionary * registerDictionary(unsigned int stackId, Dictionary *dictionary) noexcept(false);
132 
141  void loadDictionary(const std::vector<unsigned int> & stacks, const std::string & xmlPathFile) noexcept(false);
142 
150  void loadDictionary(const std::string & xmlPathFile) noexcept(false);
151 
155  void removeStacks(void) { a_stacks.clear(); }
156 
162  void removeStack(unsigned int stackId) ;
163 
164 private:
165 
166  anna::xml::DTDMemory a_dtd;
167  stack_container a_stacks;
168 
169  Engine();
170 
171  friend class anna::Singleton <Engine>;
172  friend class Dictionary; // access to 'getDictionariesDTD()'
173 };
174 
175 
176 }
177 }
178 }
179 
180 
181 #endif
Dictionary * registerDictionary(unsigned int stackId, Dictionary *dictionary) noexcept(false)
Dictionary * createDictionary(unsigned int stackId, const std::string &xmlPathFile="") noexcept(false)
void loadDictionary(const std::vector< unsigned int > &stacks, const std::string &xmlPathFile) noexcept(false)
Definition: Engine.hpp:39
const_stack_iterator stack_end() const
Definition: Engine.hpp:64
void removeStacks(void)
Definition: Engine.hpp:155
std::string asString(bool all=true) const
Definition: Singleton.hpp:76
stack_container::const_iterator const_stack_iterator
Definition: Engine.hpp:47
Definition: DTDMemory.hpp:24
bool isEmpty(void) const
Definition: Engine.hpp:74
const_stack_iterator stack_begin() const
Definition: Engine.hpp:62
std::map< unsigned int, Dictionary * > stack_container
Definition: Engine.hpp:46
Definition: Dictionary.hpp:50
stack_container::iterator stack_iterator
Definition: Engine.hpp:48
Definition: app.hpp:12
void removeStack(unsigned int stackId)
int stack_size() const
Definition: Engine.hpp:66
const Dictionary * getDictionary(unsigned int stackId) const