Changed LICENSE. Now referenced to web site and file on project root directory
[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 namespace tme {
45
46 class Avp;
47 class Message;
48 class Engine;
49
50
51 using namespace helpers::tme::codectypes;
52
53 /**
54 * Diameter TME avp generic container
55 * Manages tme-specific formats (Unsigned16, ISDNAddress, ISDNNumber)
56 */
57 class Avp : public anna::diameter::codec::Avp {
58
59   // Data containers
60   ISDNNumber *a_ISDNNumber;
61   ISDNAddress *a_ISDNAddress;
62   Unsigned16 *a_Unsigned16;
63
64   virtual void initializeByFormat() throw();
65   virtual U24 getLengthByFormat(const anna::diameter::stack::Format *stackFormat) const throw();
66   virtual std::string getXMLdataByFormat(bool & isHex, const anna::diameter::stack::Format *stackFormat) const throw();
67   virtual void fromXMLByFormat(const anna::xml::Attribute* data, const anna::xml::Attribute* hexData, const anna::diameter::stack::Format *stackFormat) throw(anna::RuntimeException);
68   virtual void codeByFormat(char* dataPart, const anna::diameter::stack::Format *stackFormat) const throw(anna::RuntimeException);
69   virtual void decodeDataPartByFormat(const char * buffer, int size, const anna::diameter::stack::Format *stackFormat) throw(anna::RuntimeException);
70   virtual void allocationByFormat(const anna::diameter::stack::Format *stackFormat) throw();
71   virtual void clearByFormat() throw();
72
73 protected:
74
75   /** Codec Engine getter: avoids have to create base engine when using its child */
76   virtual anna::diameter::codec::Engine * getEngine() const throw(anna::RuntimeException);
77
78
79 public:
80
81   /**
82   * Default constructor
83   */
84   Avp();
85
86   /**
87   * Identified constructor
88   * @param id Avp identifier as pair (code,vendorID).
89   */
90   Avp(AvpId id);
91
92   /**
93   * Destructor
94   */
95   ~Avp();
96
97
98   /** Access content for ISDNNumber Avp in order to set data part */
99   ISDNNumber *        getISDNNumber() throw(anna::RuntimeException) { assertFormat("ISDNNumber"); return a_ISDNNumber; }
100   /** Access content for ISDNAddress Avp in order to set data part */
101   ISDNAddress *        getISDNAddress() throw(anna::RuntimeException) { assertFormat("ISDNAddress"); return a_ISDNAddress; }
102   /** Access content for Unsigned16 Avp in order to set data part */
103   Unsigned16 *        getUnsigned16() throw(anna::RuntimeException) { assertFormat("Unsigned16"); return a_Unsigned16; }
104
105
106   /** Access content for ISDNNumber Avp */
107   const ISDNNumber *         getISDNNumber() const throw(anna::RuntimeException) { assertFormat("ISDNNumber"); return a_ISDNNumber; }
108   /** Access content for ISDNAddress Avp */
109   const ISDNAddress *        getISDNAddress() const throw(anna::RuntimeException) { assertFormat("ISDNAddress"); return a_ISDNAddress; }
110   /** Access content for Unsigned16 Avp */
111   const Unsigned16 *        getUnsigned16() const throw(anna::RuntimeException) { assertFormat("Unsigned16"); return a_Unsigned16; }
112
113
114
115
116   friend class Message;
117   friend class Engine;
118 };
119
120 }
121 }
122 }
123 }
124
125
126 #endif