ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | List of all members
anna::DelayMeter< _TimeUnit > Class Template Reference

#include <DelayMeter.hpp>

Public Member Functions

 DelayMeter ()
 
 DelayMeter (const DelayMeter &other)
 
void setControlPoint ()
 
void setControlPoint (const _TimeUnit &timestamp)
 
void setTopReference (const _TimeUnit &topReference)
 
void clearTopReference ()
 
void clear ()
 
_TimeUnit getValue () const
 
_TimeUnit getValue (const _TimeUnit &now) const
 
const _TimeUnit & getNow () const
 
DelayMeteroperator= (const DelayMeter &other)
 
bool operator> (const _TimeUnit &left) const
 
bool operator< (const _TimeUnit &left) const
 
std::string asString () const
 
std::string asDebugString (const char *whatis) const
 

Detailed Description

template<class _TimeUnit>
class anna::DelayMeter< _TimeUnit >

Facilita la medicion de los tiempos empleados las distintas partes de nuestra aplicacion.

Permite calcular tiempos acumulados como tiempos individuales. Por ejemplo:

#include <anna/core/DelayMeter.hpp>
void foo () {
DelayMeter <_TimeUnit> meter;
goo ();
_TimeUnit gooTime = meter.getValue ();
hoo ();
_TimeUnit goohooTime = meter.setControlPoint ();
joo ();
_TimeUnit jooTime = meter.getValue ();
}

Dónde _TimeUnit podria ser anna::Second, anna::Millisecond, anna::Microsecond

Constructor & Destructor Documentation

◆ DelayMeter() [1/2]

template<class _TimeUnit >
anna::DelayMeter< _TimeUnit >::DelayMeter ( )
inline

Constructor Inicializa la cuenta de temporizacion.

47 { a_timestamp = _TimeUnit::getTime(); }

◆ DelayMeter() [2/2]

template<class _TimeUnit >
anna::DelayMeter< _TimeUnit >::DelayMeter ( const DelayMeter< _TimeUnit > &  other)
inline

Constructor copia. Copia la cuenta de utilizacion de la instancia recibida como parametro.

Parameters
otherInstancia de la copiar los parametros para calcular el tiempo transcurrido.
54 : a_timestamp(other.a_timestamp), a_topReference(other.a_topReference) { ;}

Member Function Documentation

◆ asDebugString()

template<class _TimeUnit >
std::string anna::DelayMeter< _TimeUnit >::asDebugString ( const char *  whatis) const
inline

Devuelve la cadena de depuración de esta instancia.

Parameters
whatisTexto con el nombre lógico de esta instancia.
Returns
la cadena de depuración de esta instancia.
167  {
168  std::string result(whatis);
169  result += " { TopReference: ";
170  result += a_topReference.asString();
171  result += " | TimeStamp: ";
172  result += a_timestamp.asString();
173  result += " | Now: ";
174  result += a_now.asString();
175  return result += " }";
176  }

◆ asString()

template<class _TimeUnit >
std::string anna::DelayMeter< _TimeUnit >::asString ( void  ) const
inline

Devuelve la cadena que muestra el tiempo medido por esta instancia.

Returns
la cadena que muestra el tiempo medido por esta instancia.
160 { return getValue().asString(); }
_TimeUnit getValue() const
Definition: DelayMeter.hpp:112
Here is the call graph for this function:

◆ clear()

template<class _TimeUnit >
void anna::DelayMeter< _TimeUnit >::clear ( )
inline

Inicializa el valor del punto de referencia.

102 { a_timestamp = 0; }

◆ clearTopReference()

template<class _TimeUnit >
void anna::DelayMeter< _TimeUnit >::clearTopReference ( )
inline

Elimina el punto de referencia temporal.

97 { a_topReference = _TimeUnit(0); }

◆ getNow()

template<class _TimeUnit >
const _TimeUnit& anna::DelayMeter< _TimeUnit >::getNow ( ) const
inline

Devuelve el tiempo que se usó como referencia al calcular el retardo en getValue

Returns
El tiempo que se usó como referencia al calcular el retardo en getValue
134 { return a_now; }

◆ getValue() [1/2]

template<class _TimeUnit >
_TimeUnit anna::DelayMeter< _TimeUnit >::getValue ( ) const
inline

Devuelve el número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporización. Si se ha establecido un punto de referencia mediante setTopReference, devolverá la diferencia entre el el punto de control y la referencia, en otro caso, devolverá la diferencia entre el punto de control y el momento actual.

Returns
El número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporizacion.
Warning
Si detecta algun fallo devolvera 0.
112  {
113  a_now = (a_topReference == _TimeUnit(0)) ? _TimeUnit::getTime() : a_topReference;
114  return (a_now > a_timestamp) ? (a_now - a_timestamp) : _TimeUnit(0);
115  }

◆ getValue() [2/2]

template<class _TimeUnit >
_TimeUnit anna::DelayMeter< _TimeUnit >::getValue ( const _TimeUnit &  now) const
inline

Devuelve el número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporización. Si se ha establecido un punto de referencia mediante setTopReference, devolverá la diferencia entre el el punto de control y la referencia, en otro caso, devolverá la diferencia entre el punto de control y el momento actual.

Parameters
nowValor temporal tomado como referencia.
Returns
El número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporizacion.
Warning
Si detecta algun fallo devolvera 0.
126  {
127  return ((a_now = now) > a_timestamp) ? (a_now - a_timestamp) : _TimeUnit(0);
128  }

◆ operator<()

template<class _TimeUnit >
bool anna::DelayMeter< _TimeUnit >::operator< ( const _TimeUnit &  left) const
inline

Compara el retardo acumulado por esta instancia con el valor recibido.

Parameters
leftValor numérico con el comparar.
Returns
true si el retardo acumulado es mayor que el parámetro recibido o false en otro caso.
154 { return getValue() < left; }
_TimeUnit getValue() const
Definition: DelayMeter.hpp:112
Here is the call graph for this function:

◆ operator=()

template<class _TimeUnit >
DelayMeter& anna::DelayMeter< _TimeUnit >::operator= ( const DelayMeter< _TimeUnit > &  other)
inline

Operador copia.

Parameters
otherInstancia de la que copiar.
140 { a_timestamp = other.a_timestamp; a_topReference = other.a_topReference; return *this; }

◆ operator>()

template<class _TimeUnit >
bool anna::DelayMeter< _TimeUnit >::operator> ( const _TimeUnit &  left) const
inline

Compara el retardo acumulado por esta instancia con el valor recibido.

Parameters
leftValor numérico con el comparar.
Returns
true si el retardo acumulado es mayor que el parámetro recibido o false en otro caso.
147 { return getValue() > left; }
_TimeUnit getValue() const
Definition: DelayMeter.hpp:112
Here is the call graph for this function:

◆ setControlPoint() [1/2]

template<class _TimeUnit >
void anna::DelayMeter< _TimeUnit >::setControlPoint ( )
inline

Inicializa la cuenta de temporizacion. Este metodo es invocado automaticamente desde el contructor la clase por lo que si vamos usar esta instancia para tomar un unica medida no es necesario invocarlo.

Warning
Elimina el punto de referencia temporal que puediera haberse establecido con setTopReference.
Returns
El número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporizacion.
62  {
63  a_timestamp = _TimeUnit::getTime();
65  }
void clearTopReference()
Definition: DelayMeter.hpp:97
Here is the call graph for this function:

◆ setControlPoint() [2/2]

template<class _TimeUnit >
void anna::DelayMeter< _TimeUnit >::setControlPoint ( const _TimeUnit &  timestamp)
inline

Inicializa la cuenta de temporizacion. Este metodo es invocado automaticamente desde el contructor la clase por lo que si vamos usar esta instancia para tomar un unica medida no es necesario invocarlo.

Warning
Elimina el punto de referencia temporal que puediera haberse establecido con setTopReference.
Returns
El número de milisegundos transcurridos desde la última vez que inicializamos la cuenta de temporizacion.
Parameters
timestampValor de referencia a establecer.
75  {
76  a_timestamp = timestamp;
78  }
void clearTopReference()
Definition: DelayMeter.hpp:97
Here is the call graph for this function:

◆ setTopReference()

template<class _TimeUnit >
void anna::DelayMeter< _TimeUnit >::setTopReference ( const _TimeUnit &  topReference)
inline

Se da la posiblidad de establecer un punto de referencia temporal de forma que cuando se invoque a DelayMeter::getValue, el calculo de la diferencia de tiempo no se hará entre la marca de tiempo y el tiempo actual, sino la marca de tiempo y ésta marca de referencia.

Esta funcionalidad ha sido requerida para medir el tiempo de ejecución "real" de tareas que se ejecutan dentro de un thread. Ya que puede pasar un tiempo indeterminado desde que se termina la tarea MT (momento en el que se establecerá la marca de tiempo) y el núcleo y demás partes pueden tener conocimiento de que esa tarea ha sido finalidad.

92 { a_topReference = topReference; }

The documentation for this class was generated from the following file: