Public Member Functions | Protected Attributes | Friends | List of all members
ecl::TimeStampBase Class Reference

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 TimeStampBasestamp (const double &decimal_time_value)
 Manually set the timestamp. More...
 
const TimeStampBasestamp (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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ TimeStampBase() [1/3]

ecl::TimeStampBase::TimeStampBase ( )
inlineexplicit

Definition at line 45 of file timestamp_base.hpp.

◆ TimeStampBase() [2/3]

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.

Parameters
decimal_time_value: time units in seconds (integral part) and nanoseconds (decimal part).
Exceptions
StandardException: throws if the input arguments is not positive [debug mode only].

Definition at line 27 of file timestamp_base.cpp.

◆ TimeStampBase() [3/3]

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.

Parameters
seconds: discrete time value measured in whole seconds.
nanoseconds: fraction of a second measured in nanoseconds.
Exceptions
StandardException: throws if input arguments are not positive [debug mode only].

Definition at line 33 of file timestamp_base.cpp.

◆ ~TimeStampBase()

virtual ecl::TimeStampBase::~TimeStampBase ( )
inlinevirtual

Definition at line 68 of file timestamp_base.hpp.

Member Function Documentation

◆ msec()

long ecl::TimeStampBase::msec ( ) const
inline

Milliseconds component (after removing seconds).

Get the fractional number of milliseconds recorded in this timestamp.

Returns
long : the fractional amount of time recorded by this timestamp (in ms).

Definition at line 112 of file timestamp_base.hpp.

◆ nsec()

long ecl::TimeStampBase::nsec ( ) const
inline

Nanoseconds component (after removing seconds).

Get the fractional number of nanoseconds recorded in this timestamp.

Returns
long : the fractional amount of time recorded by this timestamp (in ns).

Definition at line 126 of file timestamp_base.hpp.

◆ operator double()

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.

◆ operator!=()

bool ecl::TimeStampBase::operator!= ( const TimeStampBase time_stamp)

Inequality operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 74 of file timestamp_base.cpp.

◆ operator+()

TimeStampBase ecl::TimeStampBase::operator+ ( const TimeStampBase time_stamp)

Sum operator that returns a new timestamp holding the sum.

Parameters
time_stamp: the rhv (timestamp to be added to this instance).
Returns
TimeStamp : the sum of the two timestamps.

Definition at line 150 of file timestamp_base.cpp.

◆ operator+=()

void ecl::TimeStampBase::operator+= ( const TimeStampBase time_stamp)

Sum operator that modifies this instance with the result.

Parameters
time_stamp: the rhv (timestamp to be added to this instance).

Definition at line 129 of file timestamp_base.cpp.

◆ operator-()

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.

Parameters
time_stamp: the rhv (timestamp to be subtracted from this instance).
Returns
TimeStamp : the difference of the two timestamps.
Exceptions
StandardException: throws if difference would create a negative timestamp [debug mode only].

Definition at line 186 of file timestamp_base.cpp.

◆ operator-=()

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.

Parameters
time_stamp: the rhv (timestamp to be subtracted from this instance).
Exceptions
StandardException: throws if difference would create a negative timestamp [debug mode only].

Definition at line 171 of file timestamp_base.cpp.

◆ operator<()

bool ecl::TimeStampBase::operator< ( const TimeStampBase time_stamp)

Less than operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 104 of file timestamp_base.cpp.

◆ operator<=()

bool ecl::TimeStampBase::operator<= ( const TimeStampBase time_stamp)

Less than or equal to operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 82 of file timestamp_base.cpp.

◆ operator==()

bool ecl::TimeStampBase::operator== ( const TimeStampBase time_stamp)

Equality operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 66 of file timestamp_base.cpp.

◆ operator>()

bool ecl::TimeStampBase::operator> ( const TimeStampBase time_stamp)

Greater than or equal to operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 115 of file timestamp_base.cpp.

◆ operator>=()

bool ecl::TimeStampBase::operator>= ( const TimeStampBase time_stamp)

Greater than or equal to operator.

Parameters
time_stamp: the rhv (timestamp) to be compared to this instance.
Returns
bool : the result of the comparison operation.

Definition at line 93 of file timestamp_base.cpp.

◆ sec()

long ecl::TimeStampBase::sec ( ) const
inline

Seconds component.

Get the current number of whole seconds recorded by this timestamp.

Returns
Seconds : the number of whole seconds recorded by this timestamp.

Definition at line 105 of file timestamp_base.hpp.

◆ stamp() [1/2]

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.

Parameters
decimal_time_value: time units in seconds (integral part) and nanoseconds (decimal part).
Exceptions
StandardException: throws if the input arguments is not positive [debug mode only].

Definition at line 46 of file timestamp_base.cpp.

◆ stamp() [2/2]

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.

Parameters
seconds: discrete time value measured in whole seconds.
nanoseconds: fraction of a second measured in nanoseconds.
Exceptions
StandardException: throws if input arguments are not positive [debug mode only].

Definition at line 52 of file timestamp_base.cpp.

◆ usec()

long ecl::TimeStampBase::usec ( ) const
inline

Microseconds component (after removing seconds).

Get the fractional number of microseconds recorded in this timestamp.

Returns
long : the fractional amount of time recorded by this timestamp (in us).

Definition at line 119 of file timestamp_base.hpp.

Friends And Related Function Documentation

◆ operator<<

template<typename OutputStream >
OutputStream& operator<< ( OutputStream &  ostream,
const TimeStampBase time_stamp 
)
friend

Definition at line 226 of file timestamp_base.hpp.

Member Data Documentation

◆ time

TimeStructure ecl::TimeStampBase::time
protected

Definition at line 217 of file timestamp_base.hpp.


The documentation for this class was generated from the following files:


ecl_time
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:29