This class provides common functionality across platforms for the timestamps. More...
#include <timestamp_base.hpp>
Public Member Functions | |
long | msec () const |
Milliseconds component (after removing seconds). More... | |
long | nsec () const |
Nanoseconds component (after removing seconds). More... | |
operator double () const | |
Disguises the timestamp as a regular double. More... | |
bool | operator!= (const TimeStampBase &time_stamp) |
TimeStampBase | operator+ (const TimeStampBase &time_stamp) |
void | operator+= (const TimeStampBase &time_stamp) |
TimeStampBase | operator- (const TimeStampBase &time_stamp) |
void | operator-= (const TimeStampBase &time_stamp) |
bool | operator< (const TimeStampBase &time_stamp) |
bool | operator<= (const TimeStampBase &time_stamp) |
bool | operator== (const TimeStampBase &time_stamp) |
bool | operator> (const TimeStampBase &time_stamp) |
bool | operator>= (const TimeStampBase &time_stamp) |
long | sec () const |
Seconds component. More... | |
const TimeStampBase & | stamp (const double &decimal_time_value) |
Manually set the timestamp. More... | |
const TimeStampBase & | stamp (const time_t &seconds, const long &nanoseconds) |
Manually sets the timestamp with the specified values. More... | |
TimeStampBase () | |
TimeStampBase (const double &decimal_time_value) | |
Default constructor. More... | |
TimeStampBase (const time_t &seconds, const long &nanoseconds) | |
Initialises the timestamp with the specified sec/nsec pair. More... | |
long | usec () const |
Microseconds component (after removing seconds). More... | |
virtual | ~TimeStampBase () |
Protected Attributes | |
TimeStructure | time |
Friends | |
template<typename OutputStream > | |
OutputStream & | operator<< (OutputStream &ostream, const TimeStampBase &time_stamp) |
This class provides common functionality across platforms for the timestamps.
Most of the operations on a timestamp class is common from one platform to the next. These functions are bundled together in this class.
Definition at line 46 of file timestamp_base.hpp.
|
inlineexplicit |
Definition at line 59 of file timestamp_base.hpp.
|
explicit |
Default constructor.
Initialise the timestamp with a default value.
Initialises the timestamp with the specified double value. Note that this is slower than the manual initialisation with a sec/nsec pair.
decimal_time_value | : time units in seconds (integral part) and nanoseconds (decimal part). |
StandardException | : throws if the input arguments is not positive [debug mode only]. |
Definition at line 31 of file timestamp_base.cpp.
ecl::TimeStampBase::TimeStampBase | ( | const time_t & | seconds, |
const long & | nanoseconds | ||
) |
Initialises the timestamp with the specified sec/nsec pair.
This is the fastest means of initialisation to a set time value.
seconds | : discrete time value measured in whole seconds. |
nanoseconds | : fraction of a second measured in nanoseconds. |
StandardException | : throws if input arguments are not positive [debug mode only]. |
Definition at line 37 of file timestamp_base.cpp.
|
inlinevirtual |
Definition at line 82 of file timestamp_base.hpp.
|
inline |
Milliseconds component (after removing seconds).
Get the fractional number of milliseconds recorded in this timestamp.
Definition at line 126 of file timestamp_base.hpp.
|
inline |
Nanoseconds component (after removing seconds).
Get the fractional number of nanoseconds recorded in this timestamp.
Definition at line 140 of file timestamp_base.hpp.
|
inline |
Disguises the timestamp as a regular double.
Converts the posix timespec structure to a double (seconds->integral part, nanoseconds->fractional part). This is sometimes useful in time calculations.
Definition at line 148 of file timestamp_base.hpp.
bool ecl::TimeStampBase::operator!= | ( | const TimeStampBase & | time_stamp | ) |
Inequality operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 78 of file timestamp_base.cpp.
TimeStampBase ecl::TimeStampBase::operator+ | ( | const TimeStampBase & | time_stamp | ) |
Sum operator that returns a new timestamp holding the sum.
time_stamp | : the rhv (timestamp to be added to this instance). |
Definition at line 154 of file timestamp_base.cpp.
void ecl::TimeStampBase::operator+= | ( | const TimeStampBase & | time_stamp | ) |
Sum operator that modifies this instance with the result.
time_stamp | : the rhv (timestamp to be added to this instance). |
Definition at line 133 of file timestamp_base.cpp.
TimeStampBase ecl::TimeStampBase::operator- | ( | const TimeStampBase & | time_stamp | ) |
Difference operator that returns a new timestamp holding the difference. Note that a difference that would result in a negative timestamp is not permitted (design requirement). Subsequently, this method will throw when in debug mode if this situation occurs.
time_stamp | : the rhv (timestamp to be subtracted from this instance). |
StandardException | : throws if difference would create a negative timestamp [debug mode only]. |
Definition at line 190 of file timestamp_base.cpp.
void ecl::TimeStampBase::operator-= | ( | const TimeStampBase & | time_stamp | ) |
Difference operator that modifies this instance with the result. Note that a difference that would result in a negative timestamp is not permitted (design requirement). Subsequently, this method will throw when in debug mode if this situation occurs.
time_stamp | : the rhv (timestamp to be subtracted from this instance). |
StandardException | : throws if difference would create a negative timestamp [debug mode only]. |
Definition at line 175 of file timestamp_base.cpp.
bool ecl::TimeStampBase::operator< | ( | const TimeStampBase & | time_stamp | ) |
Less than operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 108 of file timestamp_base.cpp.
bool ecl::TimeStampBase::operator<= | ( | const TimeStampBase & | time_stamp | ) |
Less than or equal to operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 86 of file timestamp_base.cpp.
bool ecl::TimeStampBase::operator== | ( | const TimeStampBase & | time_stamp | ) |
Equality operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 70 of file timestamp_base.cpp.
bool ecl::TimeStampBase::operator> | ( | const TimeStampBase & | time_stamp | ) |
Greater than or equal to operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 119 of file timestamp_base.cpp.
bool ecl::TimeStampBase::operator>= | ( | const TimeStampBase & | time_stamp | ) |
Greater than or equal to operator.
time_stamp | : the rhv (timestamp) to be compared to this instance. |
Definition at line 97 of file timestamp_base.cpp.
|
inline |
Seconds component.
Get the current number of whole seconds recorded by this timestamp.
Definition at line 119 of file timestamp_base.hpp.
const TimeStampBase & ecl::TimeStampBase::stamp | ( | const double & | decimal_time_value | ) |
Manually set the timestamp.
Manually sets the timestamp with the specified double value. Note that this is slower than the stamp with a sec/nsec pair.
decimal_time_value | : time units in seconds (integral part) and nanoseconds (decimal part). |
StandardException | : throws if the input arguments is not positive [debug mode only]. |
Definition at line 50 of file timestamp_base.cpp.
const TimeStampBase & ecl::TimeStampBase::stamp | ( | const time_t & | seconds, |
const long & | nanoseconds | ||
) |
Manually sets the timestamp with the specified values.
This is the fastest way of setting the timestamp.
seconds | : discrete time value measured in whole seconds. |
nanoseconds | : fraction of a second measured in nanoseconds. |
StandardException | : throws if input arguments are not positive [debug mode only]. |
Definition at line 56 of file timestamp_base.cpp.
|
inline |
Microseconds component (after removing seconds).
Get the fractional number of microseconds recorded in this timestamp.
Definition at line 133 of file timestamp_base.hpp.
|
friend |
Definition at line 232 of file timestamp_base.hpp.
|
protected |
Definition at line 231 of file timestamp_base.hpp.