X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fdiameter%2Fcodec%2FMessage.hpp;fp=include%2Fanna%2Fdiameter%2Fcodec%2FMessage.hpp;h=69aecf204bb627c53df8f4b031fa932ce32bbc0a;hb=e80e62a5cf9aacad1a9551c68c432147ef98cd29;hp=48d2b848342797fd75c8969fd8a67d64c54ba96c;hpb=c7742e2134826a05ee9c6bf89eebaa726dae0d1b;p=anna.git diff --git a/include/anna/diameter/codec/Message.hpp b/include/anna/diameter/codec/Message.hpp index 48d2b84..69aecf2 100644 --- a/include/anna/diameter/codec/Message.hpp +++ b/include/anna/diameter/codec/Message.hpp @@ -175,8 +175,23 @@ public: Message(CommandId id, Engine *engine = NULL); - /** Sets the codec engine */ - void setEngine(Engine *engine) throw() { a_engine = engine; } + /** + * Sets the codec engine. + * + * Once assigned (here or at constructor), this method SHALL NOT be used anymore. + * Also, the associated dictionary SHOULD NOT BE CHANGED through the engine, + * unless you know what are you doing. If you want to reconfigure the engine, + * first #clear the message and then you could reuse the same object with + * different configurations (execution contexts). + * + * Setting a new different engine with different stack, even same engine where the + * stack has been dynamically changed, could cause a bad behaviour depending on the + * changes: in general, if the dictionary grows, nothing bad will happen, but if + * you remove or modified some elements which were processed with a certain format, + * will be interpreted as 'unknown' with the new dictionary, and then some problems + * may occur. If you add elements (vendors, avps, messages) is not a problem. + */ + void setEngine(Engine *engine) throw(); // Length references @@ -297,9 +312,11 @@ public: @warning Request provided must be a request, in other case method do nothing. */ - void setHeaderToAnswer(const Message &request) throw() { + void setHeaderToAnswer(const Message &request) throw(anna::RuntimeException) { if(!request.getId().second) return; + a_engine = request.getEngine(); // we know this will be + setId(CommandId(request.getId().first, !request.getId().second), false /* don't clear */); setVersion(request.getVersion()); setApplicationId(request.getApplicationId()); @@ -375,7 +392,7 @@ public: @warning Request provided must be a request, in other case method do nothing. */ - void setStandardToAnswer(const Message &request, const std::string &originHost, const std::string &originRealm, int resultCode = helpers::base::AVPVALUES__Result_Code::DIAMETER_SUCCESS) throw(); + void setStandardToAnswer(const Message &request, const std::string &originHost, const std::string &originRealm, int resultCode = helpers::base::AVPVALUES__Result_Code::DIAMETER_SUCCESS) throw(anna::RuntimeException); /** @@ -443,12 +460,15 @@ public: /** Adds an avp child providing a persistent pointer (must be maintained by application). + It is not allowed to add an avp with no codec engine configured, neither if the engine + is not the same. @param avp Avp external pointer. If NULL provided, nothing is done and NULL returned. + Also NULL returned for bad engine configuration. @return Pointer to the added avp (again). */ - Avp * addAvp(Avp * avp) throw() { if(!avp) return NULL; addChild(avp); return avp; } + Avp * addAvp(Avp * avp) throw(); /** @@ -471,7 +491,7 @@ public: /** * Clears and initializes Message class information. - * Application must clear auxiliary message objects before adding Avps in a new context. + * Application must clear auxiliary message objects before adding Avps in a new context if the same object is reused. * Application don't need to clear a message object before decode operation (decode invokes #clear before any other task). * Any reimplementation must first invoke base class method. */ @@ -506,87 +526,21 @@ public: */ bool valid(Message *ptrAnswer = NULL) const throw(anna::RuntimeException); - /** Interpret xml data in order to dump over the class content. - \param messageNode Message root node + \param messageNode Message root node obtained from @functions::xmlFileTo */ void fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeException); /** - Interpret xml string representation in order to dump over the class content. - DTD validation is used in the same way that #loadXML does. - \param xmlString XML string representation with relevant information for this instance - */ - void fromXMLString(const std::string &xmlString) throw(anna::RuntimeException); - - /** - Loads an xml file based on this message DTD (could be accumulative, no initialization will be performed by this method). - -
-     
-     
-
-     
-     
-
-     
-     
-     
- - @param xmlPathFile Complete path file to the xml document which represents the diameter message - @see fromXMLString - */ - void loadXML(const std::string & xmlPathFile) throw(anna::RuntimeException); - + * Interpret a xml file in order to create a diameter message + * + * @see functions::messageXmlDocumentFromXmlFile + * @see fromXML + * + * @param xmlPathFile Complete path file to the xml document which represents the diameter message + */ + void loadXML(const std::string &xmlPathFile) throw(anna::RuntimeException); // getters