Changed LICENSE. Now referenced to web site and file on project root directory
[anna.git] / include / anna / diameter / codec / Engine.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_Engine_hpp
10 #define anna_diameter_codec_Engine_hpp
11
12
13 // STL
14 #include <string>
15
16 #include <anna/core/util/Recycler.hpp>
17
18 #include <anna/diameter/codec/Message.hpp>
19 #include <anna/diameter/codec/Avp.hpp>
20 #include <anna/diameter/codec/EngineImpl.hpp>
21
22
23 using namespace anna::diameter::codec;
24
25
26 //------------------------------------------------------------------------------
27 //---------------------------------------------------------------------- #define
28 //------------------------------------------------------------------------------
29
30
31 namespace anna {
32
33 namespace diameter {
34
35 namespace codec {
36
37
38
39 /**
40  * Standard inheritance for engine component implementation, allocating basic Avp and Message classes.
41  */
42 class Engine : public EngineImpl {
43
44 public:
45
46   static const char* getClassName() throw() { return "anna::diameter::codec::Engine"; }
47
48   Engine() : EngineImpl(getClassName()) {;}
49
50   void releaseAvp(Avp* avp) throw() {
51     if(avp == NULL) return;
52
53     //Avp* aux = static_cast <Avp*> (avp);
54 //        avp/*aux*/->clear(); // free internal data-part storage specially for grouped avps which will release its childrens
55     a_avps.release(avp/*aux*/);
56   }
57
58   void releaseMessage(Message* message) throw() {
59     if(message == NULL) return;
60
61     //Message* aux = static_cast <Message*> (message);
62 //        message/*aux*/->clear(); // free internal data-part storage specially for childrens releasing
63     a_messages.release(message/*aux*/);
64   }
65
66 protected:
67
68   anna::Recycler<Avp> a_avps;
69   anna::Recycler<Message> a_messages;
70
71   anna::diameter::codec::Avp* allocateAvp() throw() { return a_avps.create(); }
72   anna::diameter::codec::Message* allocateMessage() throw() { return a_messages.create(); }
73
74   friend class Message;
75   friend class Avp;
76 };
77
78 }
79 }
80 }
81
82 #endif
83