Loading...
Searching...
No Matches
ASSA::Timer Class Reference

`#include <Timer.h>`

## Public Member Functions

| Timer ()
| Default constructor.
| Timer (const EventHandler *eh_, const TimeVal &tm_, const TimeVal &delta_, const std::string &name_)
| Constructor used by the TimerQueue.
| Timer (const Timer &t_)
| Copy constructor.
| ~Timer ()
| Destructor: do-nothing.
Timer & | operator= (const Timer &t_)
| Assignment operator.
bool | operator< (const Timer &t_) const
| Less-that by time.
bool | operator== (const Timer &t_) const
| Equal by time.
EventHandler * | getHandler () const
| Get EventHandler pointer.
const TimeVal & | getExpirationTime () const
| Get Expiration Time.
const TimeVal & | getDeltaTime () const
| Get Delta time.
void | rescheduleExpirationTime ()
| Reschedule expiration time with Delta value.
void | dump (void)
| Dump contents to logfile.
void | set_id (const std::string &id_)
| Set Timer ID.
std::string | get_id () const
| Retrieve Timer ID.

## Private Attributes

EventHandler * | m_eh
| Pointer to EventHandler.
TimeVal | m_timer
| When the timer should be triggered.
TimeVal | m_delta
| Absolute value used when Reactor needs to reschedule the timer.
std::string | m_id
| Timer's ID.

## Detailed Description

Definition at line 35 of file Timer.h.

## Constructor & Destructor Documentation

## Timer() [1/3]

ASSA::Timer::Timer | ( |  | ) |

inline

Default constructor.

Definition at line 109 of file Timer.h.

: m_eh (NULL), m_id ("<unknown>")
{
trace("Timer::Timer");
}
trace
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition Logger.h:429
ASSA::Timer::m_eh
EventHandler * m_eh
Pointer to EventHandler.
Definition Timer.h:93
ASSA::Timer::m_id
std::string m_id
Timer's ID.
Definition Timer.h:102

References trace.

## Timer() [2/3]

ASSA::Timer::Timer | ( | const EventHandler * | eh_,
|  | const TimeVal & | tm_,
|  | const TimeVal & | delta_,
|  | const std::string & | name_
| ) |  |

inline

Constructor used by the TimerQueue.

Parameters

  eh_ | EventHandler to call upon timeout
  tm_ | Time of the day to expire the timer.
  delta_ | Absolute timeout value.
  name_ | Timer name

Definition at line 117 of file Timer.h.

: m_eh ((EventHandler*) eh_), m_timer (tm_), m_delta (delta_), m_id (name_)
{
trace("Timer::Timer(EH*, TV&)");
}
ASSA::Timer::m_timer
TimeVal m_timer
When the timer should be triggered.
Definition Timer.h:96
ASSA::Timer::m_delta
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition Timer.h:99

References trace.

## Timer() [3/3]

ASSA::Timer::Timer | ( | const Timer & | t_ | ) |

inline

Copy constructor.

Definition at line 126 of file Timer.h.

: m_eh (t_.m_eh), m_timer (t_.m_timer),
m_delta (t_.m_delta), m_id (t_.m_id)
{
trace("Timer::Timer(Timer&)");
}

References trace.

## ~Timer()

ASSA::Timer::~Timer | ( |  | ) |

inline

Destructor: do-nothing.

Definition at line 135 of file Timer.h.

{
trace("Timer::~Timer");
}

References trace.

## Member Function Documentation

## dump()

void ASSA::Timer::dump | ( | void |  | ) |

inline

Dump contents to logfile.

Definition at line 176 of file Timer.h.

{
DL((REACT,"Timer %s (EH=%s) expires at %s (delta=%s)\n",
get_id ().c_str (),
m_eh->get_id ().c_str (),
m_timer.fmtString ().c_str(),
m_delta.fmt_mm_ss_mls ().c_str()));
}
DL
#define DL(X)
A macro for writing debug message to the Logger.
Definition Logger.h:273
ASSA::EventHandler::get_id
std::string get_id() const
Retrieve EventHandler ID.
Definition EventHandler.h:157
ASSA::TimeVal::fmtString
string fmtString(const char *fmt_=NULL) const
Format timeval structure into readable format.
Definition TimeVal.cpp:146
ASSA::TimeVal::fmt_mm_ss_mls
string fmt_mm_ss_mls() const
Format timeval structure in readable format MM:SS.MLS.
Definition TimeVal.cpp:189
ASSA::Timer::get_id
std::string get_id() const
Retrieve Timer ID.
Definition Timer.h:89
ASSA::REACT
@ REACT
Class Reactor/PrioriyQueue messages
Definition LogMask.h:39

References DL, ASSA::TimeVal::fmt_mm_ss_mls(), ASSA::TimeVal::fmtString(), ASSA::EventHandler::get_id(), get_id(), m_delta, m_eh, m_timer, and ASSA::REACT.

## get_id()

std::string ASSA::Timer::get_id | ( |  | ) | const

inline

Retrieve Timer ID.

Definition at line 89 of file Timer.h.

{ return m_id; }

References m_id.

Referenced by dump().

## getDeltaTime()

const TimeVal & ASSA::Timer::getDeltaTime | ( |  | ) | const

inline

Get Delta time.

Definition at line 74 of file Timer.h.

{ return m_delta; }

References m_delta.

## getExpirationTime()

const TimeVal & ASSA::Timer::getExpirationTime | ( |  | ) | const

inline

Get Expiration Time.

Definition at line 71 of file Timer.h.

{ return m_timer; }

References m_timer.

## getHandler()

EventHandler * ASSA::Timer::getHandler | ( |  | ) | const

inline

Get EventHandler pointer.

Definition at line 68 of file Timer.h.

{ return m_eh; }

References m_eh.

## operator<()

bool ASSA::Timer::operator< | ( | const Timer & | t_ | ) | const

inline

Less-that by time.

Definition at line 153 of file Timer.h.

{
return m_timer < t_.m_timer;
}

References m_timer.

## operator=()

Timer & ASSA::Timer::operator= | ( | const Timer & | t_ | ) |

inline

Assignment operator.

Definition at line 142 of file Timer.h.

{
m_eh = t_.m_eh;
m_timer = t_.m_timer;
m_delta = t_.m_delta;
m_id = t_.m_id;
return *this;
}

References m_delta, m_eh, m_id, and m_timer.

## operator==()

bool ASSA::Timer::operator== | ( | const Timer & | t_ | ) | const

inline

Equal by time.

Definition at line 161 of file Timer.h.

{
return m_timer == t_.m_timer;
}

References m_timer.

## rescheduleExpirationTime()

void ASSA::Timer::rescheduleExpirationTime | ( |  | ) |

inline

Reschedule expiration time with Delta value.

Definition at line 168 of file Timer.h.

{
TimeVal now (TimeVal::gettimeofday ());
m_timer = now + m_delta;
}
ASSA::TimeVal::gettimeofday
static TimeVal gettimeofday()
Shields off underlying OS differences in getting current time.
Definition TimeVal.cpp:44

References ASSA::TimeVal::gettimeofday(), m_delta, and m_timer.

## set_id()

void ASSA::Timer::set_id | ( | const std::string & | id_ | ) |

inline

Set Timer ID.

ID allows Reactor and application-level code describe intelligently the kind of the Timer this is.

Definition at line 85 of file Timer.h.

{ m_id = id_; }

References m_id.

## Member Data Documentation

## m_delta

TimeVal ASSA::Timer::m_delta

private

Absolute value used when Reactor needs to reschedule the timer.

Definition at line 99 of file Timer.h.

Referenced by dump(), getDeltaTime(), operator=(), and rescheduleExpirationTime().

## m_eh

EventHandler* ASSA::Timer::m_eh

private

Pointer to EventHandler.

Definition at line 93 of file Timer.h.

Referenced by dump(), getHandler(), and operator=().

## m_id

std::string ASSA::Timer::m_id

private

Timer's ID.

Definition at line 102 of file Timer.h.

Referenced by get_id(), operator=(), and set_id().

## m_timer

TimeVal ASSA::Timer::m_timer

private

When the timer should be triggered.

Definition at line 96 of file Timer.h.

Referenced by dump(), getExpirationTime(), operator<(), operator=(), operator==(), and rescheduleExpirationTime().

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

- Timer.h