Remove dynamic exceptions
[anna.git] / include / anna / diameter / codec / tme / Avp.hpp
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_codec_tme_Avp_hpp
10 #define anna_diameter_codec_tme_Avp_hpp
11
12 // Local
13 #include <anna/diameter/codec/Avp.hpp>
14 #include <anna/diameter/helpers/tme/codectypes/codectypes.hpp>
15
16 //------------------------------------------------------------------------------
17 //---------------------------------------------------------------------- #define
18 //------------------------------------------------------------------------------
19
20 namespace anna {
21 namespace xml {
22 class Attribute;
23 }
24 }
25
26
27
28 namespace anna {
29
30 namespace diameter {
31
32 namespace helpers {
33 namespace tme {
34 namespace codectypes {
35 class Unsigned16;
36 class ISDNNumber;
37 class ISDNAddress;
38 }
39 }
40 }
41
42 namespace codec {
43
44 class Engine;
45
46 namespace tme {
47
48 class Avp;
49 class Message;
50 //class Engine;
51
52
53 using namespace helpers::tme::codectypes;
54
55 /**
56 * Diameter TME avp generic container
57 * Manages tme-specific formats (Unsigned16, ISDNAddress, ISDNNumber)
58 */
59 class Avp : public anna::diameter::codec::Avp {
60
61   // Data containers
62   ISDNNumber *a_ISDNNumber;
63   ISDNAddress *a_ISDNAddress;
64   Unsigned16 *a_Unsigned16;
65
66   virtual void initializeByFormat() ;
67   virtual U24 getLengthByFormat(const anna::diameter::stack::Format *stackFormat) const ;
68   virtual std::string getXMLdataByFormat(bool & isHex, const anna::diameter::stack::Format *stackFormat) const ;
69   virtual void fromXMLByFormat(const anna::xml::Attribute* data, const anna::xml::Attribute* hexData, const anna::diameter::stack::Format *stackFormat) noexcept(false);
70   virtual void codeByFormat(char* dataPart, const anna::diameter::stack::Format *stackFormat) const noexcept(false);
71   virtual void decodeDataPartByFormat(const char * buffer, int size, const anna::diameter::stack::Format *stackFormat) noexcept(false);
72   virtual void allocationByFormat(const anna::diameter::stack::Format *stackFormat) ;
73   virtual void clearByFormat() ;
74
75 //protected:
76
77 //  /** Codec Engine getter: avoids have to create base engine when using its child */
78 //  virtual anna::diameter::codec::Engine * getEngine() const noexcept(false);
79
80
81 public:
82
83   /**
84   * Default constructor
85   * @param engine Codec engine used
86   */
87   Avp(Engine *engine = NULL) : anna::diameter::codec::Avp(engine) {;}
88
89   /**
90   * Identified constructor
91   * @param id Avp identifier as pair (code,vendor-id).
92   * @param engine Codec engine used
93   */
94   Avp(AvpId id, Engine *engine = NULL) : anna::diameter::codec::Avp(id, engine) {;}
95
96
97   /**
98   * Destructor
99   */
100   ~Avp();
101
102
103   /** Access content for ISDNNumber Avp in order to set data part */
104   ISDNNumber *        getISDNNumber() noexcept(false) { assertFormat("ISDNNumber"); return a_ISDNNumber; }
105   /** Access content for ISDNAddress Avp in order to set data part */
106   ISDNAddress *        getISDNAddress() noexcept(false) { assertFormat("ISDNAddress"); return a_ISDNAddress; }
107   /** Access content for Unsigned16 Avp in order to set data part */
108   Unsigned16 *        getUnsigned16() noexcept(false) { assertFormat("Unsigned16"); return a_Unsigned16; }
109
110
111   /** Access content for ISDNNumber Avp */
112   const ISDNNumber *         getISDNNumber() const noexcept(false) { assertFormat("ISDNNumber"); return a_ISDNNumber; }
113   /** Access content for ISDNAddress Avp */
114   const ISDNAddress *        getISDNAddress() const noexcept(false) { assertFormat("ISDNAddress"); return a_ISDNAddress; }
115   /** Access content for Unsigned16 Avp */
116   const Unsigned16 *        getUnsigned16() const noexcept(false) { assertFormat("Unsigned16"); return a_Unsigned16; }
117
118
119
120
121   friend class Message;
122   friend class anna::diameter::codec::Engine;
123 };
124
125 }
126 }
127 }
128 }
129
130
131 #endif