libassa
3.5.1
|
#include <TimeVal.h>
Public Types | |
enum | { gmt , loc } |
Public Member Functions | |
TimeVal () | |
Default constructor. More... | |
TimeVal (long sec_, long msec_) | |
Constructor from seconds/microseconds pair. More... | |
TimeVal (double d_) | |
Constructor from double. More... | |
TimeVal (const timeval &tv_) | |
Constructor from struct timeval . More... | |
TimeVal (const TimeVal &tv_) | |
Copy constructor. More... | |
operator double () const | |
Implicit conversion to double. More... | |
void | sec (long sec_) |
Set seconds. More... | |
long | sec (void) const |
Get secons. More... | |
void | msec (long msec_) |
Set microseconds. More... | |
long | msec (void) const |
Get microseconds. More... | |
long | millisec () const |
Convert tv_usec's microseconds (=1/1,000,000 sec) to milliseconds (=1/1,000 sec). More... | |
void | tz (int tz_) |
Set timezone. More... | |
int | tz (void) const |
Get timezone. More... | |
TimeVal & | operator= (const TimeVal &tv_) |
TimeVal & | operator+= (const TimeVal &rhs_) |
Addition. More... | |
TimeVal & | operator-= (const TimeVal &rhs_) |
Substraction. More... | |
bool | operator< (const TimeVal &rhs_) const |
Comparison. More... | |
bool | operator== (const TimeVal &rhs_) const |
Equality. More... | |
string | fmtString (const char *fmt_=NULL) const |
Format timeval structure into readable format. More... | |
string | fmt_hh_mm_ss () const |
Format timeval structure in readable format HH:MM:SS. More... | |
string | fmt_hh_mm_ss_mls () const |
Format timeval structure in readable format HH:MM:SS.MLS. More... | |
string | fmt_mm_ss () const |
Format timeval structure in readable format MM:SS. More... | |
string | fmt_mm_ss_mls () const |
Format timeval structure in readable format MM:SS.MLS. More... | |
string | fmt_ss_mls () const |
Format timeval structure in readable format SS.MLS. More... | |
void | dump_to_log (const string &name_="") const |
Dump value of struct timeval to the log file with mask TRACE = DBG_APP15. More... | |
Static Public Member Functions | |
static TimeVal | zeroTime () |
Static that returns zero timeval: {0,0}. More... | |
static TimeVal | gettimeofday () |
Shields off underlying OS differences in getting current time. More... | |
Protected Member Functions | |
void | init (long, long, int) |
Internal initialization common to most constructors. More... | |
Private Member Functions | |
void | normalize () |
Normalization after arithmetic operation. More... | |
Private Attributes | |
int | m_tz |
Time zone. More... | |
Static Private Attributes | |
static TimeVal | m_zero |
Zero time value. More... | |
Friends | |
TimeVal | operator+ (const TimeVal &lhs_, const TimeVal &rhs_) |
Addition. More... | |
TimeVal | operator- (const TimeVal &lhs_, const TimeVal &rhs_) |
Substraction. More... | |
bool | operator> (const TimeVal &lhs_, const TimeVal &rhs_) |
Comparison. More... | |
bool | operator!= (const TimeVal &lhs_, const TimeVal &rhs_) |
Comparison. More... | |
bool | operator<= (const TimeVal &lhs_, const TimeVal &rhs_) |
Comparison. More... | |
bool | operator>= (const TimeVal &lhs_, const TimeVal &rhs_) |
Comparison. More... | |
|
inline |
Default constructor.
Sets time to 0 sec. 0 usecs. To get current time, use TimeVal (gettimeofday());
Definition at line 195 of file TimeVal.h.
|
inline |
|
inline |
Constructor from double.
Definition at line 209 of file TimeVal.h.
References normalize().
|
inline |
|
inline |
void TimeVal::dump_to_log | ( | const string & | name_ = "" | ) | const |
Dump value of struct timeval to the log file with mask TRACE = DBG_APP15.
Definition at line 226 of file TimeVal.cpp.
References DL, fmt_mm_ss_mls(), ASSA::Singleton< Logger >::get_instance(), millisec(), msec(), ASSA::REACT, sec(), and trace.
|
inline |
Format timeval structure in readable format HH:MM:SS.
Definition at line 247 of file TimeVal.h.
References fmtString().
string TimeVal::fmt_hh_mm_ss_mls | ( | ) | const |
Format timeval structure in readable format HH:MM:SS.MLS.
Definition at line 169 of file TimeVal.cpp.
References gmt, m_tz, and millisec().
|
inline |
Format timeval structure in readable format MM:SS.
Definition at line 254 of file TimeVal.h.
References fmtString().
string TimeVal::fmt_mm_ss_mls | ( | ) | const |
Format timeval structure in readable format MM:SS.MLS.
Definition at line 188 of file TimeVal.cpp.
References gmt, m_tz, and millisec().
Referenced by ASSA::Timer::dump(), and dump_to_log().
string TimeVal::fmt_ss_mls | ( | ) | const |
Format timeval structure in readable format SS.MLS.
Definition at line 207 of file TimeVal.cpp.
References gmt, m_tz, and millisec().
string TimeVal::fmtString | ( | const char * | fmt_ = NULL | ) | const |
Format timeval structure into readable format.
Default format is CCYY/DDD HH:MM:SS.MMM which is de fasco for the software. To get something different, pass fmt_ format string as specified by strftime(3). Popular format is "%c" which will return something like: "Fri Oct 1 10:54:27 1999". Note that timezone aspect of formatting time is controlled by tz() member function.
fmt_ | Format string as in strftime(3) |
Definition at line 145 of file TimeVal.cpp.
Referenced by ASSA::Logger_Impl::add_timestamp(), ASSA::Timer::dump(), ASSA::TimerQueue::expire(), fmt_hh_mm_ss(), fmt_mm_ss(), and ASSA::Reactor::registerTimerHandler().
|
static |
Shields off underlying OS differences in getting current time.
Definition at line 43 of file TimeVal.cpp.
References EPOCHFILETIME.
Referenced by ASSA::Logger_Impl::add_timestamp(), ASSA::Reactor::calculateTimeout(), ASSA::Reactor::dispatch(), ASSA::Reactor::registerTimerHandler(), ASSA::Timer::rescheduleExpirationTime(), ASSA::Reactor::waitForEvents(), and ASSA::TimerCountdown::~TimerCountdown().
|
inlineprotected |
Internal initialization common to most constructors.
Definition at line 185 of file TimeVal.h.
References m_tz, and normalize().
Referenced by operator=(), and TimeVal().
|
inline |
Convert tv_usec's microseconds (=1/1,000,000 sec) to milliseconds (=1/1,000 sec).
Definition at line 240 of file TimeVal.h.
References msec().
Referenced by dump_to_log(), fmt_hh_mm_ss_mls(), fmt_mm_ss_mls(), and fmt_ss_mls().
|
inline |
Set microseconds.
Definition at line 70 of file TimeVal.h.
Referenced by ASSA::Logger_Impl::add_timestamp(), and ASSA::Reactor::registerTimerHandler().
|
inline |
Get microseconds.
Definition at line 73 of file TimeVal.h.
Referenced by dump_to_log(), and millisec().
|
private |
Normalization after arithmetic operation.
Definition at line 111 of file TimeVal.cpp.
References ONE_SECOND.
Referenced by init(), operator+=(), operator-=(), and TimeVal().
|
inline |
|
inline |
|
inline |
|
inline |
Set seconds.
Definition at line 64 of file TimeVal.h.
Referenced by ASSA::Reactor::registerTimerHandler().
|
inline |
|
inline |
Set timezone.
Definition at line 81 of file TimeVal.h.
References m_tz.
Referenced by ASSA::Logger_Impl::add_timestamp().
|
inline |
|
inlinestatic |
Static that returns zero timeval: {0,0}.
Definition at line 157 of file TimeVal.h.
References m_zero.
Referenced by ASSA::Reactor::calculateTimeout(), and ASSA::TimerCountdown::~TimerCountdown().
|
private |
Time zone.
Definition at line 175 of file TimeVal.h.
Referenced by fmt_hh_mm_ss_mls(), fmt_mm_ss_mls(), fmt_ss_mls(), fmtString(), init(), operator=(), TimeVal(), and tz().
|
staticprivate |