Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
DUtils::Timestamp Class Reference

Timestamp. More...

#include <Timestamp.h>

Public Types

enum  tOptions { NONE = 0, CURRENT_TIME = 0x1, ZERO = 0x2 }
 Options to initiate a timestamp. More...
 

Public Member Functions

bool empty () const
 
string Format (bool machine_friendly=false) const
 
double getFloatTime () const
 
string getStringTime () const
 
void getTime (unsigned long &secs, unsigned long &usecs) const
 
Timestamp minus (unsigned long s, unsigned long us) const
 
Timestamp operator+ (double s) const
 
Timestampoperator+= (double s)
 
double operator- (const Timestamp &t) const
 
Timestamp operator- (double s) const
 
Timestampoperator-= (double s)
 
bool operator< (const Timestamp &t) const
 
bool operator<= (const Timestamp &t) const
 
bool operator== (const Timestamp &t) const
 
bool operator> (const Timestamp &t) const
 
bool operator>= (const Timestamp &t) const
 
Timestamp plus (unsigned long s, unsigned long us) const
 
void setTime (unsigned long secs, unsigned long usecs)
 
void setTime (const string &stime)
 
void setTime (double s)
 
void setToCurrentTime ()
 
 Timestamp (Timestamp::tOptions option=NONE)
 
virtual ~Timestamp (void)
 

Static Public Member Functions

static string Format (double s)
 

Protected Attributes

unsigned long m_secs
 Seconds. More...
 
unsigned long m_usecs
 Microseconds. More...
 

Detailed Description

Timestamp.

Definition at line 19 of file Timestamp.h.

Member Enumeration Documentation

Options to initiate a timestamp.

Enumerator
NONE 
CURRENT_TIME 
ZERO 

Definition at line 24 of file Timestamp.h.

Constructor & Destructor Documentation

Timestamp::Timestamp ( Timestamp::tOptions  option = NONE)

Creates a timestamp

Parameters
optionoption to set the initial time stamp

Definition at line 39 of file Timestamp.cpp.

Timestamp::~Timestamp ( void  )
virtual

Destructor

Definition at line 47 of file Timestamp.cpp.

Member Function Documentation

bool Timestamp::empty ( ) const

Says if the timestamp is "empty": seconds and usecs are both 0, as when initiated with the ZERO flag

Returns
true iif secs == usecs == 0

Definition at line 51 of file Timestamp.cpp.

string Timestamp::Format ( bool  machine_friendly = false) const

Returns the timestamp in a human-readable string

Parameters
machine_friendlyif true, the returned string is formatted to yyyymmdd_hhmmss, without weekday or spaces
Note
This has not been tested under Windows
The timestamp is truncated to seconds

Definition at line 197 of file Timestamp.cpp.

string Timestamp::Format ( double  s)
static

Returns a string version of the elapsed time in seconds, with the format xd hh:mm:ss, hh:mm:ss, mm:ss or s.us

Parameters
selapsed seconds (given by getFloatTime) to format

Definition at line 223 of file Timestamp.cpp.

double Timestamp::getFloatTime ( ) const

Returns this timestamp as the number of seconds in (long) float format

Definition at line 93 of file Timestamp.cpp.

string Timestamp::getStringTime ( ) const

Returns this timestamp as the number of seconds in fixed length string format

Definition at line 97 of file Timestamp.cpp.

void DUtils::Timestamp::getTime ( unsigned long &  secs,
unsigned long &  usecs 
) const
inline

Returns the timestamp in seconds and microseconds

Parameters
secsseconds
usecsmicroseconds

Definition at line 71 of file Timestamp.h.

Timestamp Timestamp::minus ( unsigned long  s,
unsigned long  us 
) const

Returns a copy of this timestamp - s seconds - us microseconds

Parameters
sseconds
usmicroseconds

Definition at line 149 of file Timestamp.cpp.

Timestamp Timestamp::operator+ ( double  s) const

Returns a copy of this timestamp + s seconds

Parameters
sseconds

Definition at line 119 of file Timestamp.cpp.

Timestamp & Timestamp::operator+= ( double  s)

Adds s seconds to this timestamp and returns a reference to itself

Parameters
sseconds
Returns
reference to this timestamp

Definition at line 107 of file Timestamp.cpp.

double Timestamp::operator- ( const Timestamp t) const

Returns the difference in seconds between this timestamp (greater) and t (smaller) If the order is swapped, a negative number is returned

Parameters
ttimestamp to subtract from this timestamp
Returns
difference in seconds

Definition at line 103 of file Timestamp.cpp.

Timestamp Timestamp::operator- ( double  s) const

Returns a copy of this timestamp - s seconds

Parameters
sseconds

Definition at line 141 of file Timestamp.cpp.

Timestamp & Timestamp::operator-= ( double  s)

Substracts s seconds to this timestamp and returns a reference to itself

Parameters
sseconds
Returns
reference to this timestamp

Definition at line 113 of file Timestamp.cpp.

bool Timestamp::operator< ( const Timestamp t) const

Returns whether this timestamp is at the past of t

Parameters
t

Definition at line 177 of file Timestamp.cpp.

bool Timestamp::operator<= ( const Timestamp t) const

Returns whether this timestamp is at the past of (or is the same as) t

Parameters
t

Definition at line 184 of file Timestamp.cpp.

bool Timestamp::operator== ( const Timestamp t) const

Returns whether this timestamp and t represent the same instant

Parameters
t

Definition at line 191 of file Timestamp.cpp.

bool Timestamp::operator> ( const Timestamp t) const

Returns whether this timestamp is at the future of t

Parameters
t

Definition at line 163 of file Timestamp.cpp.

bool Timestamp::operator>= ( const Timestamp t) const

Returns whether this timestamp is at the future of (or is the same as) t

Parameters
t

Definition at line 170 of file Timestamp.cpp.

Timestamp Timestamp::plus ( unsigned long  s,
unsigned long  us 
) const

Returns a copy of this timestamp + s seconds + us microseconds

Parameters
sseconds
usmicroseconds

Definition at line 127 of file Timestamp.cpp.

void DUtils::Timestamp::setTime ( unsigned long  secs,
unsigned long  usecs 
)
inline

Sets the timestamp from seconds and microseconds

Parameters
secsseconds
usecsmicroseconds

Definition at line 61 of file Timestamp.h.

void Timestamp::setTime ( const string &  stime)

Sets the timestamp from a string with the time in seconds

Parameters
stimestring such as "1235603336.036609"

Definition at line 73 of file Timestamp.cpp.

void Timestamp::setTime ( double  s)

Sets the timestamp from a number of seconds from the epoch

Parameters
sseconds from the epoch

Definition at line 87 of file Timestamp.cpp.

void Timestamp::setToCurrentTime ( )

Sets this instance to the current time

Definition at line 56 of file Timestamp.cpp.

Member Data Documentation

unsigned long DUtils::Timestamp::m_secs
protected

Seconds.

Definition at line 196 of file Timestamp.h.

unsigned long DUtils::Timestamp::m_usecs
protected

Microseconds.

Definition at line 198 of file Timestamp.h.


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


orb_slam2_with_maps_odom
Author(s): teng zhang
autogenerated on Fri Sep 25 2020 03:24:47