X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Ftimex%2FContext.hpp;h=8d72b4cd2186566bc8e7716d719d5b478eadffb4;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=ce20571851525bf0c033a6540ba6024ef8f37192;hpb=3e258840b15577cb8bda3cdedd0b9b88e16404b3;p=anna.git diff --git a/include/anna/timex/Context.hpp b/include/anna/timex/Context.hpp index ce20571..8d72b4c 100644 --- a/include/anna/timex/Context.hpp +++ b/include/anna/timex/Context.hpp @@ -1,37 +1,9 @@ -// ANNA - Anna is Not Nothingness Anymore -// -// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo -// -// https://bitbucket.org/testillano/anna -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Authors: eduardo.ramos.testillano@gmail.com -// cisco.tierra@gmail.com +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // #ifndef anna_timex_Context_hpp @@ -88,7 +60,7 @@ public: * \return La nueva transación que ya habrá sido activada. */ Transaction* open(const Tid& tid, const int classType = 0) - throw(RuntimeException) { + noexcept(false) { Transaction* result = NULL; { Guard guard(a_mutex, "timex::Context::open"); @@ -138,18 +110,18 @@ public: * \return La transación correspondiente al identificador recibido. Puede ser NULL. */ Transaction* find(const Tid& tid, const Exception::Mode::_v emode = Exception::Mode::Throw) - throw(RuntimeException) { + noexcept(false) { Guard guard(a_mutex, "timex::Context::find"); transaction_iterator ii = a_transactions.find(tid); Transaction* result = (ii != a_transactions.end()) ? transaction(ii) : NULL; if(result == NULL) { - if(Exception::Mode::Throw) { + if(emode == Exception::Mode::Throw) { std::string msg("Transaction: "); msg += identifierAsString(tid); msg += " | Tid not found"; throw RuntimeException(msg, ANNA_FILE_LOCATION); - } else if(Exception::Mode::Trace && Logger::isActive(Logger::Warning)) { + } else if(emode == Exception::Mode::Trace && Logger::isActive(Logger::Warning)) { std::string msg("Transaction: "); msg += identifierAsString(tid); msg += " | Tid not found"; @@ -166,7 +138,7 @@ public: * \return El identificador de aplicación indicado en el método #open. */ const Tid& getIdentifier(const Transaction* transaction) const - throw(RuntimeException) { + noexcept(false) { if(transaction == NULL) throw RuntimeException("timex::Context::getIdentifier | Can not work with NULL transaction", ANNA_FILE_LOCATION); @@ -187,7 +159,7 @@ public: * \param transaction Transación a terminar. Si fuera NULL este método no tiene ningún efecto. */ void close(Transaction* transaction) - throw() { + { if(transaction == NULL) return; @@ -210,7 +182,7 @@ public: * \return Un documento XML con la información relevante de esta clase. */ virtual xml::Node* asXML(xml::Node* parent) const - throw() { + { xml::Node* result = parent->createChild("timex.Context"); result->createAttribute("Size", a_transactions.size()); result->createAttribute("AvgSize", (a_counter == 0) ? 0 : a_accSize / a_counter); @@ -228,7 +200,7 @@ public: * Puede ser NULL. */ static const Context* getInstance(const Transaction* transaction) - throw(RuntimeException) { + noexcept(false) { if(transaction == NULL) throw RuntimeException("timex::Context::getInstance | Can not work with NULL transaction", ANNA_FILE_LOCATION); @@ -259,14 +231,14 @@ protected: * tenga que gestionar varios tipos de transaciones u operaciones. * \return Una nueva transación que puede ser usada por este contexto. */ - virtual Transaction* createTransaction(const int classType) throw() = 0; + virtual Transaction* createTransaction(const int classType) = 0; /** * Método virtual puro que liberá el espacio asociado a la transación recibida como parámetro. * Lo más adecuado sería implementar este método mediate el uso del patrón #anna::Recycler. * \param transaction Transación a liberar. */ - virtual void releaseTransaction(Transaction* transaction) throw() = 0; + virtual void releaseTransaction(Transaction* transaction) = 0; /** * Método virtual puro que debe devolver una \em std::string correspondiente al valor del identificador @@ -274,14 +246,14 @@ protected: * \param tid Identificador único que la transación. * \return una \em std::string correspondiente al valor del identificador recibido como parámetro. */ - virtual std::string identifierAsString(const Tid& tid) const throw() = 0; + virtual std::string identifierAsString(const Tid& tid) const = 0; /** * Método virtual puro que debe devolver la clave de aplicación asociada a una transación * \param tid Puntero que apunta a la clave de aplicación usada para acceder a una transacción. * \return La clave de aplicación correspondiente al puntero recibido como parámetro. */ - virtual const Tid& contextAsIdentifier(const void* tid) const throw() = 0; + virtual const Tid& contextAsIdentifier(const void* tid) const = 0; private: typedef typename std::map transaction_container; @@ -298,7 +270,7 @@ private: /* Método re-implementado de timex::TimeEventObserver */ void release(timex::TimeEvent* event) - throw() { + { Transaction* tt = static_cast (event); Guard guard(a_mutex, "timex::Context::release"); // Calcula la duración media de las transaciones de este contexto. @@ -326,7 +298,7 @@ private: a_accSize += a_transactions.size(); } - static Transaction* transaction(transaction_iterator ii) throw() { return ii->second; } + static Transaction* transaction(transaction_iterator ii) { return ii->second; } }; }