ANNA Suite  2020b
Multipurpose development suite for Telco applications
Vendor.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_Vendor_hpp
10 #define anna_diameter_stack_Vendor_hpp
11 
12 // Local
13 #include <anna/config/defines.hpp>
15 
16 #include <anna/config/defines.hpp>
19 
20 // STL
21 #include <string>
22 
23 
24 
25 namespace anna {
26 namespace xml {
27 class Node;
28 }
29 }
30 
31 
32 
33 namespace anna {
34 
35 namespace diameter {
36 
37 namespace stack {
38 
39 
40 //------------------------------------------------------------------------------
41 //----------------------------------------------------------------- class Vendor
42 //------------------------------------------------------------------------------
46 class Vendor {
47  S32 a_id;
48  std::string a_name;
49 
50 public:
51 
52  struct Code {
53  enum _v {
54  None = -1, // Initialized
55  Ietf = 0,
56  Nokia = 94,
57  Ericsson = 193,
58  TresGPP = 10415,
59  Telefonicaid = 5189,
60  Etsi = 13019
61  };
62 
64 
70  static const char* asText(const Code::_v v) noexcept(false) {
71  return asCString(v);
72  }
73  };
74 
75 
76  Vendor() {};
77  ~Vendor() {};
78 
79 
80  // get
81  S32 getId(void) const { return a_id; }
82  const S8 * getName(void) const { return a_name.c_str(); }
83 
84  // helpers
85  bool isVendorSpecific(void) const { return (a_id > 0); }
86 
87 
88  std::string asString(void) const ;
89  anna::xml::Node* asXML(anna::xml::Node* parent) const ;
90 
91  // operators
92  friend bool operator == (const Vendor & v1, const Vendor & v2) { return ((v1.getId() == v2.getId())); }
93 
94  // set
95  void setId(const S32 & id) noexcept(false) {
96  if(id < 0) throw anna::RuntimeException("Negative vendor-id not allowed", ANNA_FILE_LOCATION);
97 
98  a_id = id;
99  }
100 
101  void setName(const std::string & n) noexcept(false) {
102  if(n == "") throw anna::RuntimeException("Empty vendor-name string not allowed", ANNA_FILE_LOCATION);
103 
104  a_name = n;
105  }
106 };
107 
108 
109 }
110 }
111 }
112 
113 
114 #endif
const S8 * getName(void) const
Definition: Vendor.hpp:82
Definition: Vendor.hpp:46
~Vendor()
Definition: Vendor.hpp:77
#define anna_declare_enum(name)
Definition: define.autoenum.hpp:48
Definition: Node.hpp:56
Vendor()
Definition: Vendor.hpp:76
int32_t S32
Definition: defines.hpp:78
xml::Node Node
Definition: Node.hpp:21
Definition: Vendor.hpp:52
void setName(const std::string &n) noexcept(false)
Definition: Vendor.hpp:101
void setId(const S32 &id) noexcept(false)
Definition: Vendor.hpp:95
Definition: app.hpp:12
static const char * asText(const Code::_v v) noexcept(false)
Definition: Vendor.hpp:70
S32 getId(void) const
Definition: Vendor.hpp:81
#define ANNA_FILE_LOCATION
Definition: defines.hpp:23
bool isVendorSpecific(void) const
Definition: Vendor.hpp:85
Definition: RuntimeException.hpp:23
char S8
Definition: defines.hpp:66
_v
Definition: Vendor.hpp:53