libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Attributes | List of all members
ASSA::Timer Class Reference

#include <Timer.h>

Public Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 35 of file Timer.h.

Constructor & Destructor Documentation

ASSA::Timer::Timer ( )
inline

Default constructor.

Definition at line 110 of file Timer.h.

References trace.

111  : m_eh (NULL), m_id ("<unknown>")
112 {
113  trace("Timer::Timer");
114 }
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition: Logger.h:429
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102
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 118 of file Timer.h.

References trace.

120  : m_eh ((EventHandler*) eh_), m_timer (tm_), m_delta (delta_), m_id (name_)
121 {
122  trace("Timer::Timer(EH*, TV&)");
123 }
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition: Logger.h:429
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
ASSA::Timer::Timer ( const Timer t_)
inline

Copy constructor.

Definition at line 127 of file Timer.h.

References trace.

128  : m_eh (t_.m_eh), m_timer (t_.m_timer),
129  m_delta (t_.m_delta), m_id (t_.m_id)
130 {
131  trace("Timer::Timer(Timer&)");
132 }
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition: Logger.h:429
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
ASSA::Timer::~Timer ( )
inline

Destructor: do-nothing.

Definition at line 136 of file Timer.h.

References trace.

137 {
138  trace("Timer::~Timer");
139 }
#define trace(s)
trace() is used to trace function call chain in C++ program.
Definition: Logger.h:429

Member Function Documentation

void ASSA::Timer::dump ( void  )
inline

Dump contents to logfile.

Definition at line 177 of file Timer.h.

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

Referenced by ASSA::PriorityQueue_STLPQ< T, Compare >::dump(), and ASSA::TimerQueue::expire().

178 {
179  DL((REACT,"Timer %s (EH=%s) expires at %s (delta=%s)\n",
180  get_id ().c_str (),
181  m_eh->get_id ().c_str (),
182  m_timer.fmtString ().c_str(),
183  m_delta.fmt_mm_ss_mls ().c_str()));
184 }
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
#define DL(X)
A macro for writing debug message to the Logger.
Definition: Logger.h:273
std::string get_id() const
Retrieve Timer ID.
Definition: Timer.h:89
string fmtString(const char *fmt_=NULL) const
Format timeval structure into readable format.
Definition: TimeVal.cpp:146
Class Reactor/PrioriyQueue messages.
Definition: LogMask.h:39
string fmt_mm_ss_mls() const
Format timeval structure in readable format MM:SS.MLS.
Definition: TimeVal.cpp:189
std::string get_id() const
Retrieve EventHandler ID.
Definition: EventHandler.h:157
std::string ASSA::Timer::get_id ( ) const
inline

Retrieve Timer ID.

Definition at line 89 of file Timer.h.

References m_id.

Referenced by dump(), and ASSA::TimerQueue::expire().

89 { return m_id; }
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102
const TimeVal& ASSA::Timer::getDeltaTime ( ) const
inline

Get Delta time.

Definition at line 74 of file Timer.h.

References m_delta.

74 { return m_delta; }
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
const TimeVal& ASSA::Timer::getExpirationTime ( ) const
inline

Get Expiration Time.

Definition at line 71 of file Timer.h.

References m_timer.

Referenced by ASSA::TimerQueue::expire().

71 { return m_timer; }
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
EventHandler* ASSA::Timer::getHandler ( ) const
inline

Get EventHandler pointer.

Definition at line 68 of file Timer.h.

References m_eh.

Referenced by ASSA::TimerQueue::expire(), and ASSA::PriorityQueue_STLPQ< T, Compare >::remove().

68 { return m_eh; }
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
bool ASSA::Timer::operator< ( const Timer t_) const
inline

Less-that by time.

Definition at line 155 of file Timer.h.

References m_timer.

156 {
157  return m_timer < t_.m_timer;
158 }
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
Timer & ASSA::Timer::operator= ( const Timer t_)
inline

Assignment operator.

Definition at line 143 of file Timer.h.

References m_delta, m_eh, m_id, and m_timer.

144 {
145  m_eh = t_.m_eh;
146  m_timer = t_.m_timer;
147  m_delta = t_.m_delta;
148  m_id = t_.m_id;
149 
150  return *this;
151 }
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
EventHandler * m_eh
Pointer to EventHandler.
Definition: Timer.h:93
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
bool ASSA::Timer::operator== ( const Timer t_) const
inline

Equal by time.

Definition at line 162 of file Timer.h.

References m_timer.

163 {
164  return m_timer == t_.m_timer;
165 }
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
void ASSA::Timer::rescheduleExpirationTime ( )
inline

Reschedule expiration time with Delta value.

Definition at line 169 of file Timer.h.

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

170 {
171  TimeVal now (TimeVal::gettimeofday ());
172  m_timer = now + m_delta;
173 }
TimeVal m_delta
Absolute value used when Reactor needs to reschedule the timer.
Definition: Timer.h:99
TimeVal m_timer
When the timer should be triggered.
Definition: Timer.h:96
static TimeVal gettimeofday()
Shields off underlying OS differences in getting current time.
Definition: TimeVal.cpp:44
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.

References m_id.

85 { m_id = id_; }
std::string m_id
Timer&#39;s ID.
Definition: Timer.h:102

Member Data Documentation

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().

EventHandler* ASSA::Timer::m_eh
private

Pointer to EventHandler.

Definition at line 93 of file Timer.h.

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

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().

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: