-// 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
// 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.
//
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 */
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.
* 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.
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;
};
}