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). | |
long | nsec () const |
Nanoseconds component (after removing seconds). | |
operator double () const | |
Disguises the timestamp as a regular double. | |
bool | operator!= (const TimeStampBase &time_stamp) |
TimeStampBase | operator+ (const TimeStampBase &time_stamp) |
void | operator+= (const TimeStampBase &time_stamp) |
TimeStampBase | operator- (const TimeStampBase &time_stamp) ecl_assert_throw_decl(StandardException) |
void | operator-= (const TimeStampBase &time_stamp) ecl_assert_throw_decl(StandardException) |
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. | |
const TimeStampBase & | stamp (const double &decimal_time_value) ecl_assert_throw_decl(StandardException) |
Manually set the timestamp. | |
const TimeStampBase & | stamp (const time_t &seconds, const long &nanoseconds) ecl_assert_throw_decl(StandardException) |
Manually sets the timestamp with the specified values. | |
TimeStampBase () | |
TimeStampBase (const double &decimal_time_value) ecl_assert_throw_decl(StandardException) | |
Default constructor. | |
TimeStampBase (const time_t &seconds, const long &nanoseconds) ecl_assert_throw_decl(StandardException) | |
Initialises the timestamp with the specified sec/nsec pair. | |
long | usec () const |
Microseconds component (after removing seconds). | |
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 40 of file timestamp_base.hpp.
ecl::TimeStampBase::TimeStampBase | ( | ) | [inline, explicit] |
Definition at line 45 of file timestamp_base.hpp.
ecl::TimeStampBase::TimeStampBase | ( | const double & | decimal_time_value | ) | [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 27 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 33 of file timestamp_base.cpp.
virtual ecl::TimeStampBase::~TimeStampBase | ( | ) | [inline, virtual] |
Definition at line 68 of file timestamp_base.hpp.
long ecl::TimeStampBase::msec | ( | ) | const [inline] |
Milliseconds component (after removing seconds).
Get the fractional number of milliseconds recorded in this timestamp.
Definition at line 112 of file timestamp_base.hpp.
long ecl::TimeStampBase::nsec | ( | ) | const [inline] |
Nanoseconds component (after removing seconds).
Get the fractional number of nanoseconds recorded in this timestamp.
Definition at line 126 of file timestamp_base.hpp.
ecl::TimeStampBase::operator double | ( | ) | const [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 134 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 74 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 150 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 129 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 186 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 171 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 104 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 82 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 66 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 115 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 93 of file timestamp_base.cpp.
long ecl::TimeStampBase::sec | ( | ) | const [inline] |
Seconds component.
Get the current number of whole seconds recorded by this timestamp.
Definition at line 105 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 46 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 52 of file timestamp_base.cpp.
long ecl::TimeStampBase::usec | ( | ) | const [inline] |
Microseconds component (after removing seconds).
Get the fractional number of microseconds recorded in this timestamp.
Definition at line 119 of file timestamp_base.hpp.
OutputStream& operator<< | ( | OutputStream & | ostream, |
const TimeStampBase & | time_stamp | ||
) | [friend] |
Definition at line 226 of file timestamp_base.hpp.
TimeStructure ecl::TimeStampBase::time [protected] |
Definition at line 217 of file timestamp_base.hpp.