From: Eduardo Ramos Testillano Date: Tue, 29 Sep 2015 12:46:37 +0000 (+0200) Subject: Message cleared on demand (if you want to reuse and the codec engine may be different) X-Git-Tag: REFACTORING_TESTING_LIBRARY~106 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=6a05cda7553cf39d5b14539f9f4b9cf829c156a6;p=anna.git Message cleared on demand (if you want to reuse and the codec engine may be different) --- diff --git a/example/diameter/batchConverter/main.cpp b/example/diameter/batchConverter/main.cpp index 5ccf1c8..f909d89 100644 --- a/example/diameter/batchConverter/main.cpp +++ b/example/diameter/batchConverter/main.cpp @@ -70,6 +70,7 @@ void _exit(const std::string &message, int resultCode = 1) { // Decodes a diameter message coming from a datablock void decodeDataBlock(const anna::DataBlock &db/*, unsigned int & detectedApplicationId*/) throw() { try { + G_codecMsg.clear(); // perhaps we will need another codec engine ... G_codecMsg.decode(db); } catch(RuntimeException &ex) { _exit(ex.asString()); diff --git a/include/anna/diameter/codec/Message.hpp b/include/anna/diameter/codec/Message.hpp index 69aecf2..4c3e6e6 100644 --- a/include/anna/diameter/codec/Message.hpp +++ b/include/anna/diameter/codec/Message.hpp @@ -232,9 +232,8 @@ public: Sets the command identifier and clear the former content. @param id Command identifier as pair (code,request-indicator). - @param _clear Message will be cleared when updating the command identifier (default behaviour). */ - void setId(CommandId id, bool _clear = true) throw(anna::RuntimeException); + void setId(CommandId id) throw(anna::RuntimeException); /** Same as #setId but providing dictionary logical name for Avp searched @@ -317,7 +316,7 @@ public: a_engine = request.getEngine(); // we know this will be - setId(CommandId(request.getId().first, !request.getId().second), false /* don't clear */); + setId(CommandId(request.getId().first, !request.getId().second)); setVersion(request.getVersion()); setApplicationId(request.getApplicationId()); setHopByHop(request.getHopByHop()); // The same Hop-by-Hop Identifier in the request is used in the answer (RFC 6733 Section 6.2). diff --git a/source/diameter/codec/Message.cpp b/source/diameter/codec/Message.cpp index b5d87f6..049e85a 100644 --- a/source/diameter/codec/Message.cpp +++ b/source/diameter/codec/Message.cpp @@ -191,9 +191,7 @@ bool Message::flagsOK(int &rc) const throw() { //------------------------------------------------------------------------------ //------------------------------------------------------------- Message::setId() //------------------------------------------------------------------------------ -void Message::setId(CommandId id, bool _clear) throw(anna::RuntimeException) { - // Clear class content: - if(_clear) clear(); +void Message::setId(CommandId id) throw(anna::RuntimeException) { // Id assignment: a_id = id; @@ -822,7 +820,8 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); } - setId(stackCommand->getId(), false /* don't clear */); + setId(stackCommand->getId()); + // 'P', 'E' and 'T' flags: bool activateP = pbit ? (pbit->getValue() == "yes") : false; bool activateE = ebit ? (ebit->getValue() == "yes") : false; diff --git a/source/diameter/codec/tme/Avp.cpp b/source/diameter/codec/tme/Avp.cpp index 6875c87..cd0fab9 100644 --- a/source/diameter/codec/tme/Avp.cpp +++ b/source/diameter/codec/tme/Avp.cpp @@ -20,22 +20,6 @@ using namespace anna; using namespace anna::diameter::codec::tme; - -////------------------------------------------------------------------------------ -////------------------------------------------------------------------- Avp::Avp() -////------------------------------------------------------------------------------ -//Avp::Avp(Engine *engine) : anna::diameter::codec::Avp(engine) { -// initialize(); -//} -// -////------------------------------------------------------------------------------ -////------------------------------------------------------------------- Avp::Avp() -////------------------------------------------------------------------------------ -//Avp::Avp(AvpId id, Engine *engine)/* : anna::diameter::codec::Avp(id, engine)*/ { -// initialize(); -// setId(id); -//} - //------------------------------------------------------------------------------ //------------------------------------------------------------------ Avp::~Avp() //------------------------------------------------------------------------------