1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of the copyright holder nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_core_oam_Counter_hpp
38 #define anna_core_oam_Counter_hpp
40 #include <anna/core/util/defines.hpp>
51 Permite un sistema rapido para registrar situaciones ocurridas en las aplicaciones.
55 typedef unsigned int type_t;
58 Devuelve el nombre logico del contador, que coincidira con el indicado a la hora
59 de crear el contador mediante el metodo CounterScope::create.
60 \return El nombre logico del contador.
62 const std::string& getName() const throw() { return a_name; }
65 Devuelve la referencia logica de este contador. Sera el numero resultante de combinar
66 el numero de ambito en el que esta registrado y el numero de contador dentro de este
68 \return La referencia logica de este contador.
70 int getReference() const throw();
73 * Devuelve el valor actual de este contador. Este valor se podrĂ¡ a cero cada vez que los contadores
75 * \return El valor actual de este contador.
77 type_t getValue() const throw() { return a_value; }
80 * Devuelve el valor acumulado de este contador.
81 * \return El valor acumulado de este contador.
83 U64 getAccumulatedValue() const throw() { return a_accValue; }
86 Operador de conversion.
87 \return El valor asociado a este contador.
89 operator type_t () const throw() { return a_value; }
92 Inicializa el valor de este contador.
94 void reset() throw() { a_value = 0; }
97 Inicializa el valor acumulado de este contador.
98 \return Devuelve 'true' si fue reseteado, 'false' si ya lo estaba
100 bool resetAcc() throw() { bool result = (a_accValue != 0); a_accValue = 0; return result; }
104 Devuelve una cadena con la informacion relevante de este objeto.
105 \return Una cadena con la informacion relevante de este objeto.
107 std::string asString() const throw();
110 CounterScope& a_scope;
116 Counter(CounterScope& scope, const int id, const char* name);
117 Counter(const Counter&);
119 void debug() const throw();
121 friend class CounterScope;