ASSA::Timer Class Reference

#include <Timer.h>

List of all members.

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 32 of file Timer.h.


Constructor & Destructor Documentation

ASSA::Timer::Timer (   )  [inline]
 

Default constructor.

Definition at line 107 of file Timer.h.

References trace.

00108     : m_eh (NULL), m_id ("<unknown>")
00109 {
00110     trace("Timer::Timer");
00111 }

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 115 of file Timer.h.

References trace.

00117     : m_eh ((EventHandler*) eh_), m_timer (tm_), m_delta (delta_), m_id (name_)
00118 {
00119     trace("Timer::Timer(EH*, TV&)");
00120 }

ASSA::Timer::Timer (  const Timer &  t_  )  [inline]
 

Copy constructor.

Definition at line 124 of file Timer.h.

References trace.

00125     : m_eh (t_.m_eh), m_timer (t_.m_timer), 
00126       m_delta (t_.m_delta), m_id (t_.m_id)
00127 {
00128     trace("Timer::Timer(Timer&)");
00129 }

ASSA::Timer::~Timer (   )  [inline]
 

Destructor: do-nothing.

Definition at line 133 of file Timer.h.

References trace.

00134 {
00135     trace("Timer::~Timer");
00136 }


Member Function Documentation

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

Dump contents to logfile.

Definition at line 174 of file Timer.h.

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.

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

00175 {
00176     DL((REACT,"Timer %s (EH=%s) expires at %s (delta=%s)\n",
00177         get_id ().c_str (),
00178         m_eh->get_id ().c_str (), 
00179         m_timer.fmtString ().c_str(),
00180         m_delta.fmt_mm_ss_mls ().c_str()));
00181 }

std::string ASSA::Timer::get_id (   )  const [inline]
 

Retrieve Timer ID.

Definition at line 86 of file Timer.h.

References m_id.

Referenced by dump().

00086 { return m_id; }

const TimeVal& ASSA::Timer::getDeltaTime (   )  const [inline]
 

Get Delta time.

Definition at line 71 of file Timer.h.

References m_delta.

00071 { return m_delta; }

const TimeVal& ASSA::Timer::getExpirationTime (   )  const [inline]
 

Get Expiration Time.

Definition at line 68 of file Timer.h.

References m_timer.

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

00068 { return m_timer; }

EventHandler* ASSA::Timer::getHandler (   )  const [inline]
 

Get EventHandler pointer.

Definition at line 65 of file Timer.h.

References m_eh.

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

00065 { return m_eh; }

bool ASSA::Timer::operator< (  const Timer &  t_  )  const [inline]
 

Less-that by time.

Definition at line 152 of file Timer.h.

References m_timer.

00153 {
00154     return m_timer < t_.m_timer;
00155 }

Timer & ASSA::Timer::operator= (  const Timer &  t_  )  [inline]
 

Assignment operator.

Definition at line 140 of file Timer.h.

References m_delta, m_eh, m_id, and m_timer.

00141 {
00142     m_eh    = t_.m_eh;
00143     m_timer = t_.m_timer;
00144     m_delta = t_.m_delta;
00145     m_id    = t_.m_id;
00146 
00147     return *this;
00148 }

bool ASSA::Timer::operator== (  const Timer &  t_  )  const [inline]
 

Equal by time.

Definition at line 159 of file Timer.h.

References m_timer.

00160 {
00161     return m_timer == t_.m_timer;
00162 }

void ASSA::Timer::rescheduleExpirationTime (   )  [inline]
 

Reschedule expiration time with Delta value.

Definition at line 166 of file Timer.h.

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

00167 {
00168     TimeVal now (TimeVal::gettimeofday ());
00169     m_timer = now + m_delta;
00170 }

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 82 of file Timer.h.

References m_id.

00082 { m_id = id_; }


Member Data Documentation

TimeVal ASSA::Timer::m_delta [private]
 

Absolute value used when Reactor needs to reschedule the timer.

Definition at line 96 of file Timer.h.

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

EventHandler* ASSA::Timer::m_eh [private]
 

Pointer to EventHandler.

Definition at line 90 of file Timer.h.

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

std::string ASSA::Timer::m_id [private]
 

Timer's ID.

Definition at line 99 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 93 of file Timer.h.

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


The documentation for this class was generated from the following file:
Generated on Tue Jun 20 10:36:23 2006 for libassa by  doxygen 1.4.6