ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | List of all members
anna::timex::Meter Class Reference

#include <Meter.hpp>

Inheritance diagram for anna::timex::Meter:
Inheritance graph
[legend]

Public Member Functions

 Meter ()
 
 Meter (const Meter &other)
 
Millisecond setControlPoint ()
 
void setTopReference (const Millisecond &topReference)
 
void clearTopReference ()
 
Millisecond getDelay () const
 
Meteroperator= (const Millisecond &timestamp)
 
Meteroperator= (const Meter &other)
 

Detailed Description

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

Permite calcular tiempos acumulados como tiempos individuales. Por ejemplo:

#include <anna.timex.Meter.h>
void foo () {
timex::Meter meter;
goo ();
Millisecond gooTime = meter.getDelay ();
hoo ();
Millisecond goohooTime = meter.setControlPoint ();
joo ();
Millisecond jooTime = meter.getDelay ();
}

Constructor & Destructor Documentation

◆ Meter() [1/2]

anna::timex::Meter::Meter ( )
inline

Constructor Inicializa la cuenta de temporizacion.

47 { a_timestamp = functions::millisecond(); a_topReference = 0; }
static Millisecond millisecond()
Definition: functions.hpp:379
Here is the call graph for this function:

◆ Meter() [2/2]

anna::timex::Meter::Meter ( const Meter 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 = 0; ;}

Member Function Documentation

◆ clearTopReference()

void anna::timex::Meter::clearTopReference ( )
inline

Elimina el punto de referencia temporal.

88 { a_topReference = 0; }

◆ getDelay()

Millisecond anna::timex::Meter::getDelay ( ) 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.
98  {
99  Millisecond now = (a_topReference == 0) ? functions::millisecond() : a_topReference;
100  return (now > a_timestamp) ? (now - a_timestamp) : (Millisecond)0;
101  }
static Millisecond millisecond()
Definition: functions.hpp:379
Here is the call graph for this function:

◆ operator=() [1/2]

Meter& anna::timex::Meter::operator= ( const Millisecond timestamp)
inline

Operador copia.

Parameters
timestampMilisegundo en el que inicilizar la cuenta de esta instancia.
Warning
Elimina el punto de referencia temporal que puediera haberse establecido con setTopReference.
See also
anna::functions::millisecond.
109 { a_timestamp = timestamp; a_topReference = 0; return *this; }

◆ operator=() [2/2]

Meter& anna::timex::Meter::operator= ( const Meter other)
inline

Operador copia.

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

◆ setControlPoint()

Millisecond anna::timex::Meter::setControlPoint ( void  )
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  Millisecond now = functions::millisecond();
64  Millisecond result = (now > a_timestamp) ? (now - a_timestamp) : (Millisecond)0;
65  a_timestamp = now;
67  return result;
68  }
void clearTopReference()
Definition: Meter.hpp:88
static Millisecond millisecond()
Definition: functions.hpp:379
Here is the call graph for this function:

◆ setTopReference()

void anna::timex::Meter::setTopReference ( const Millisecond topReference)
inline

Se da la posiblidad de establecer un punto de referencia temporal de forma que cuando se invoque a Meter::getDelay, 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.

83 { a_topReference = topReference; }

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