X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fcore%2Foam%2FCounterScope.hpp;h=2447b5cce40af32fb0f07e6dcfaf63bd50130aa4;hb=39033fd99e58e994a5e98c1060dcc79e0d81f9c9;hp=21bca01c1a12fa5c808319b4bc3ef357911a9bca;hpb=4e12ac57e93c052f716a6305ad8fc099c45899d1;p=anna.git diff --git a/include/anna/core/oam/CounterScope.hpp b/include/anna/core/oam/CounterScope.hpp index 21bca01..2447b5c 100644 --- a/include/anna/core/oam/CounterScope.hpp +++ b/include/anna/core/oam/CounterScope.hpp @@ -1,8 +1,8 @@ -// ANNA - Anna is Not 'N' Anymore +// ANNA - Anna is Not Nothingness Anymore // // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo // -// https://bitbucket.org/testillano/anna +// http://redmine.teslayout.com/projects/anna-suite // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions @@ -14,7 +14,7 @@ // 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 +// * Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -51,57 +51,14 @@ namespace xml { class Node; } -namespace timex { -class Engine; -} - namespace oam { -class CounterManager; /** Ámbito de contadores. Contiene un grupo logico de contadores. */ class CounterScope : public Mutex { public: - /** - * Accesor que permite modificar el valor de los contadores asociados a un ámbito de forma segura. - * \see anna::oam::CounterScope. - */ - class Safe { - public: - /** - * Constructor. - * \param counterScope Ámbito de contadores a bloquear para aplicar cambios. - * \param Texto que identifica el punto de bloqueo. - */ - Safe(timex::Engine* ttcc, CounterScope& counterScope, const char* whatis); - - /** - * Destructor. - */ - ~Safe() throw(); - - /** - * Incrementa el contador recibido como parámetro. - * \warning La invocación a este método deberá hacerse sobre una sección crítica que proteja - * a este ámbito. - * \return El valor actual del contador. - */ - Counter::type_t increment(const int counter, const Counter::type_t value) throw(RuntimeException) { return a_counterScope.increment(counter, value); } - - /** - * Establece el valor del contador recibido como parámetro. - * \warning La invocación a este método deberá hacerse sobre una sección crítica que proteja - * a este ámbito. - * \return El valor actual del contador. - */ - Counter::type_t assign(const int counter, const Counter::type_t value) throw(RuntimeException) { return a_counterScope.assign(counter, value); } - - private: - CounterScope& a_counterScope; - Guard* a_guards [2]; - }; static const int MaxCounter = 1000; /**< Numero maximo de contador por cada ambito */ @@ -118,18 +75,11 @@ public: const std::string& getName() const throw() { return a_name; } /** - Devuelve el identificador del ambito, que coincidira con el indicado a la hora - de crear el contador mediante el metodo CounterManager::create. + Devuelve el identificador del ambito \return El identificador del ambito. */ const int getId() const throw() { return a_id; } - /** - Devuelve el gestor de contadores asociado a este ambito. - \return El gestor de contadores asociado a este ambito. - */ - CounterManager& getCounterManager() throw() { return a_counterManager; } - /** Crea un nuevo contador. \param counter Numero logico del contador a crear. Debera ser menor de MaxCounter. @@ -184,7 +134,7 @@ public: * Devuelve el valor actual acumulado del contador pasado como parámetro. * \param counter Identificador del contedor cuyo valor acumulado queremos obtener. */ - Unsigned64 getAccValue(const int counter) const throw(RuntimeException); + U64 getAccValue(const int counter) const throw(RuntimeException); /** * Resetea los valores acumulados totales de los contadores incluidos en el ámbito. @@ -193,22 +143,20 @@ public: int resetAccValues() throw(RuntimeException); private: - CounterManager& a_counterManager; const int a_id; const std::string a_name; Counter* a_counters [MaxCounter]; - CounterScope(CounterManager& counterManager, const int id, const char* name) : + CounterScope(const int id, const char* name) : Mutex(Mutex::Mode::Recursive), - a_counterManager(counterManager), a_id(id), a_name(name) { anna_memset(a_counters, 0, sizeof(a_counters)); } friend class Safe; - friend class CounterManager; - // CounterScope + friend class Handler; + friend class Module; }; }