List of all members
gnsstk::PosixTime Class Reference

Detailed Description

This class encapsulates the struct timespec time representation defined by POSIX as a replacement (?) for timeval.

Note
struct timeval used by gettimeofday() is expected to represent a real time, but there is no such expectation for struct timespec, which may be used to represent a variety of clocks, including but not limited to real-time. It is assumed that the timespec is a real-time clock value when converting to and from CommonTime.

Definition at line 62 of file PosixTime.hpp.

#include <PosixTime.hpp>

Inheritance diagram for gnsstk::PosixTime:
Inheritance graph
[legend]

Public Member Functions

PosixTime Basic Operations

Default and Copy Constructors, Assignment Operator and Destructor.

 PosixTime (int sec=0, int nsec=0, TimeSystem tsys=TimeSystem::Unknown)
 
 PosixTime (struct timespec t, TimeSystem tsys=TimeSystem::Unknown)
 
 PosixTime (const PosixTime &right)
 
 PosixTime (const TimeTag &right)
 
 PosixTime (const CommonTime &right)
 
PosixTimeoperator= (const PosixTime &right)
 
virtual ~PosixTime ()
 Virtual Destructor. More...
 
virtual CommonTime convertToCommonTime () const
 
virtual void convertFromCommonTime (const CommonTime &ct)
 
virtual std::string printf (const std::string &fmt) const
 
virtual std::string printError (const std::string &fmt) const
 
virtual bool setFromInfo (const IdToValue &info)
 
virtual std::string getPrintChars () const
 
virtual std::string getDefaultFormat () const
 Return a string containing the default format to use in printing. More...
 
virtual bool isValid () const
 Returns true if this object's members are valid, false otherwise. More...
 
virtual void reset ()
 Reset this object to the default state. More...
 
- Public Member Functions inherited from gnsstk::TimeTag
virtual std::string asString () const
 
bool changeTimeSystem (TimeSystem timeSys)
 
bool changeTimeSystem (TimeSystem timeSys, TimeSystemConverter *conv)
 
TimeSystem getTimeSystem () const
 Obtain time system info (enum). More...
 
virtual operator CommonTime () const
 
virtual void scanf (const std::string &str, const std::string &fmt)
 
void setTimeSystem (const TimeSystem &timeSys)
 Set method for internal variable timeSystem (enum). More...
 
 TimeTag ()
 Default constructor. More...
 
 TimeTag (const TimeSystem &ts)
 Constructor. More...
 
virtual ~TimeTag ()
 Virtual Destructor. More...
 

PosixTime Comparison Operators

All comparison operators have a parameter "right" which corresponds to the PosixTime object to the right of the symbol. All comparison operators are const and return true on success and false on failure.

struct timespec ts
 
virtual bool operator== (const PosixTime &right) const
 
virtual bool operator!= (const PosixTime &right) const
 
virtual bool operator< (const PosixTime &right) const
 
virtual bool operator> (const PosixTime &right) const
 
virtual bool operator<= (const PosixTime &right) const
 
virtual bool operator>= (const PosixTime &right) const
 

Additional Inherited Members

- Public Types inherited from gnsstk::TimeTag
typedef std::map< char, std::string > IdToValue
 
- Static Public Member Functions inherited from gnsstk::TimeTag
static void checkTimeSystem (TimeSystem ts1, TimeSystem ts2)
 
static std::string getError ()
 This returns the default error string for the TimeTag classes. More...
 
static std::string getFormatPrefixFloat ()
 
static std::string getFormatPrefixInt ()
 
static void getInfo (const std::string &str, const std::string &fmt, IdToValue &info)
 
- Protected Attributes inherited from gnsstk::TimeTag
TimeSystem timeSystem
 time system (representation) of the data More...
 

Constructor & Destructor Documentation

◆ PosixTime() [1/5]

gnsstk::PosixTime::PosixTime ( int  sec = 0,
int  nsec = 0,
TimeSystem  tsys = TimeSystem::Unknown 
)
inline

Default Constructor. All elements are initialized to zero.

Definition at line 75 of file PosixTime.hpp.

◆ PosixTime() [2/5]

gnsstk::PosixTime::PosixTime ( struct timespec  t,
TimeSystem  tsys = TimeSystem::Unknown 
)
inline

struct timespec Constructor. Sets time according to the given struct timespec.

Definition at line 83 of file PosixTime.hpp.

◆ PosixTime() [3/5]

gnsstk::PosixTime::PosixTime ( const PosixTime right)
inline

Copy Constructor.

Parameters
righta reference to the PosixTime object to copy

Definition at line 93 of file PosixTime.hpp.

◆ PosixTime() [4/5]

gnsstk::PosixTime::PosixTime ( const TimeTag right)
inline

Alternate Copy Constructor. Takes a const TimeTag reference and copies its contents via conversion to CommonTime.

Parameters
righta const reference to the BasicTime object to copy
Exceptions
InvalidRequeston over-/under-flow

Definition at line 104 of file PosixTime.hpp.

◆ PosixTime() [5/5]

gnsstk::PosixTime::PosixTime ( const CommonTime right)
inline

Alternate Copy Constructor. Takes a const CommonTime reference and copies its contents via the convertFromCommonTime method.

Parameters
righta const reference to the CommonTime object to copy
Exceptions
InvalidRequeston over-/under-flow

Definition at line 116 of file PosixTime.hpp.

◆ ~PosixTime()

virtual gnsstk::PosixTime::~PosixTime ( )
inlinevirtual

Virtual Destructor.

Definition at line 129 of file PosixTime.hpp.

Member Function Documentation

◆ convertFromCommonTime()

void gnsstk::PosixTime::convertFromCommonTime ( const CommonTime ct)
virtual
Exceptions
InvalidRequestif ct cannot be correctly represented in this TimeTag object.

This is the earliest CommonTime for which PosixTimes are valid.

This is the latest CommonTime for which PosixTimes are valid. (2^31 - 1) s and 999999 us

Implements gnsstk::TimeTag.

Definition at line 71 of file PosixTime.cpp.

◆ convertToCommonTime()

CommonTime gnsstk::PosixTime::convertToCommonTime ( ) const
virtual
Exceptions
InvalidRequestif this TimeTag cannot be correctly represented by a CommonTime object.

Implements gnsstk::TimeTag.

Definition at line 54 of file PosixTime.cpp.

◆ getDefaultFormat()

virtual std::string gnsstk::PosixTime::getDefaultFormat ( ) const
inlinevirtual

Return a string containing the default format to use in printing.

Implements gnsstk::TimeTag.

Definition at line 162 of file PosixTime.hpp.

◆ getPrintChars()

virtual std::string gnsstk::PosixTime::getPrintChars ( ) const
inlinevirtual

Return a string containing the characters that this class understands when printing times.

Implements gnsstk::TimeTag.

Definition at line 156 of file PosixTime.hpp.

◆ isValid()

bool gnsstk::PosixTime::isValid ( ) const
virtual

Returns true if this object's members are valid, false otherwise.

Implements gnsstk::TimeTag.

Definition at line 173 of file PosixTime.cpp.

◆ operator!=()

bool gnsstk::PosixTime::operator!= ( const PosixTime right) const
virtual

Definition at line 207 of file PosixTime.cpp.

◆ operator<()

bool gnsstk::PosixTime::operator< ( const PosixTime right) const
virtual

Any (wildcard) type exception allowed, otherwise must be same time systems

Definition at line 212 of file PosixTime.cpp.

◆ operator<=()

bool gnsstk::PosixTime::operator<= ( const PosixTime right) const
virtual

Definition at line 242 of file PosixTime.cpp.

◆ operator=()

PosixTime & gnsstk::PosixTime::operator= ( const PosixTime right)

Assignment Operator.

Parameters
righta const reference to the PosixTime to copy
Returns
a reference to this PosixTime

Definition at line 46 of file PosixTime.cpp.

◆ operator==()

bool gnsstk::PosixTime::operator== ( const PosixTime right) const
virtual

Any (wildcard) type exception allowed, otherwise must be same time systems

Definition at line 190 of file PosixTime.cpp.

◆ operator>()

bool gnsstk::PosixTime::operator> ( const PosixTime right) const
virtual

Definition at line 237 of file PosixTime.cpp.

◆ operator>=()

bool gnsstk::PosixTime::operator>= ( const PosixTime right) const
virtual

Definition at line 248 of file PosixTime.cpp.

◆ printError()

std::string gnsstk::PosixTime::printError ( const std::string &  fmt) const
virtual

This function works similarly to printf. Instead of filling the format with data, it fills with error messages.

Implements gnsstk::TimeTag.

Definition at line 123 of file PosixTime.cpp.

◆ printf()

std::string gnsstk::PosixTime::printf ( const std::string &  fmt) const
virtual

This function formats this time to a string. The exceptions thrown would only be due to problems parsing the fmt string.

Implements gnsstk::TimeTag.

Definition at line 102 of file PosixTime.cpp.

◆ reset()

void gnsstk::PosixTime::reset ( )
virtual

Reset this object to the default state.

Implements gnsstk::TimeTag.

Definition at line 184 of file PosixTime.cpp.

◆ setFromInfo()

bool gnsstk::PosixTime::setFromInfo ( const IdToValue info)
virtual

Set this object using the information provided in info.

Parameters
infothe IdToValue object to which this object shall be set.
Returns
true if this object was successfully set using the data in info, false if not.

Implements gnsstk::TimeTag.

Definition at line 144 of file PosixTime.cpp.

Member Data Documentation

◆ ts

struct timespec gnsstk::PosixTime::ts

Definition at line 187 of file PosixTime.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:45