X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fcommand_client.cpp;fp=src%2Fcommand_client.cpp;h=5d7169232acb3e07775a46d684e3466ee276b439;hp=52ca0f15774ad89403b01758bd32d2ec59756bf2;hb=696c95c2808d6f88df2b348f9e77fc66c9068976;hpb=9e76c81586915f9ff6f413d9fefec9b7be7cad31 diff --git a/src/command_client.cpp b/src/command_client.cpp index 52ca0f1..5d71692 100644 --- a/src/command_client.cpp +++ b/src/command_client.cpp @@ -39,8 +39,15 @@ using namespace std; namespace libt2n { +/** + * Constructor + * @param _c connection for this command. Ownership of the pointer is outside. + * @param _command_timeout_usec timeout until the command has to be completed + * @param _hello_timeout_usec timeout until hello has to be received + */ command_client::command_client(client_connection* _c, long long _command_timeout_usec, long long _hello_timeout_usec) : c(_c) + , constructorException(NULL) { command_timeout_usec=_command_timeout_usec; hello_timeout_usec=_hello_timeout_usec; @@ -60,8 +67,7 @@ command_client::command_client(client_connection* _c, long long _command_timeout c->close(); // store a copy of the exception that you can find out details about the error later - std::auto_ptr tmp(e.clone()); - constructorException=tmp; + constructorException = e.clone(); } catch (...) { @@ -70,6 +76,18 @@ command_client::command_client(client_connection* _c, long long _command_timeout } } +/** + * Destructor + */ +command_client::~command_client() +{ + if (constructorException) + { + delete constructorException; + constructorException = NULL; + } +} + /** @brief replace the connection currently in use with a new one @param _c pointer to the new connection @@ -259,7 +277,7 @@ void command_client::send_command(command* cmd, result_container &res) (*ostr) << "sending command, decoded data: " << std::endl; boost::archive::xml_oarchive xo(*ostr); xo << BOOST_SERIALIZATION_NVP(cc); - } + } c->write(ofs.str());