Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TimeSpec Struct Reference

Class wrapper for timespec structure to modify. More...

#include <TimeSpec.h>

Inheritance diagram for sf::TimeSpec:
Collaboration diagram for sf::TimeSpec:

Public Types

typedef long nsec_type
 Integer type to indicate nanoseconds.
 

Public Member Functions

 TimeSpec ()
 Default constructor.
 
 TimeSpec (const TimeSpec &ts)
 Copy constructor.
 
 TimeSpec (TimeSpec &&ts)=default
 Move constructor.
 
TimeSpecoperator= (TimeSpec &&)=default
 Move assignment operator is default.
 
 TimeSpec (const timespec &ts)
 Parent copy constructor.
 
 TimeSpec (double sec)
 Initialize using seconds with a floating point.
 
 TimeSpec (time_t sec, nsec_type nsec)
 Initialize using seconds and nanoseconds.
 
TimeSpecoperator= (const timespec &ts)
 Assignment operator using base structure.
 
bool isZero () const
 Test if it has been set and thus not-zero.
 
 operator bool () const
 Test if it has been set and thus not-zero.
 
void clear ()
 clear this instance.
 
bool operator>= (const timespec &ts) const
 Compare operator.
 
bool operator> (const timespec &ts) const
 Compare operator.
 
bool operator< (const timespec &ts) const
 Compare operator.
 
bool operator<= (const timespec &ts) const
 Compare operator.
 
bool operator== (const timespec &ts) const
 Compare operator.
 
bool operator!= (const timespec &ts) const
 Compare operator.
 
TimeSpecoperator= (const TimeSpec &ts)
 Assignment operator.
 
TimeSpecoperator+= (nsec_type nsec)
 Operator to add nanoseconds.
 
TimeSpecoperator-= (nsec_type nsec)
 Operator to add nanoseconds.
 
TimeSpecoperator+= (const timespec &t)
 Operator to add another timespec.
 
TimeSpecoperator-= (const timespec &t)
 Operator to subtract another timespec.
 
TimeSpec operator+ (const timespec &t) const
 Operator to add another timespec.
 
TimeSpec operator- (const timespec &t) const
 Operator to add another timespec.
 
TimeSpecassign (double sec)
 Assigns a double as seconds.
 
TimeSpecassign (const timespec &ts)
 Assigns a timespec base type.
 
TimeSpecrandomize (double factor=0.1)
 Modifies the current value using the passed factor where 0.1 is + or - 10%.
 
TimeSpecsetTimeOfDay ()
 assign the current time.
 
TimeSpecadd (time_t sec, nsec_type nsec)
 Adds seconds and nanoseconds to the current value.
 
TimeSpecadd (const timespec &ts)
 Adds a timespec base type to the current value.
 
TimeSpecsub (const timespec &ts)
 Subtracts a timespec base type from the current value.
 
TimeSpecassign (time_t sec, nsec_type nsec)
 Assigns seconds and nanoseconds to the current value.
 
double toDouble () const
 Gets the time value as a double.
 
time_t toMilliSecs () const
 Gets the time value as a double.
 
std::string toString () const
 Returns the time as toDouble() result converted to a string.
 

Detailed Description

Class wrapper for timespec structure to modify.

Member Typedef Documentation

◆ nsec_type

Integer type to indicate nanoseconds.

Constructor & Destructor Documentation

◆ TimeSpec() [1/6]

sf::TimeSpec::TimeSpec ( )
inline

Default constructor.

◆ TimeSpec() [2/6]

sf::TimeSpec::TimeSpec ( const TimeSpec ts)
inline

Copy constructor.

◆ TimeSpec() [3/6]

sf::TimeSpec::TimeSpec ( TimeSpec &&  ts)
default

Move constructor.

◆ TimeSpec() [4/6]

sf::TimeSpec::TimeSpec ( const timespec &  ts)
inlineexplicit

Parent copy constructor.

◆ TimeSpec() [5/6]

sf::TimeSpec::TimeSpec ( double  sec)
inlineexplicit

Initialize using seconds with a floating point.

Parameters
secSeconds.

◆ TimeSpec() [6/6]

sf::TimeSpec::TimeSpec ( time_t  sec,
nsec_type  nsec 
)
inlineexplicit

Initialize using seconds and nanoseconds.

Parameters
secSeconds.
nsecNanoseconds.

Member Function Documentation

◆ add() [1/2]

TimeSpec & sf::TimeSpec::add ( const timespec &  ts)

Adds a timespec base type to the current value.

Parameters
tsBase class.
Returns
Itself

◆ add() [2/2]

TimeSpec & sf::TimeSpec::add ( time_t  sec,
nsec_type  nsec 
)

Adds seconds and nanoseconds to the current value.

Parameters
secSeconds.
nsecNanoseconds.
Returns
Itself.

◆ assign() [1/3]

TimeSpec & sf::TimeSpec::assign ( const timespec &  ts)

Assigns a timespec base type.

Parameters
tsInstance.
Returns
Itself.

◆ assign() [2/3]

TimeSpec & sf::TimeSpec::assign ( double  sec)

Assigns a double as seconds.

Parameters
secSeconds.
Returns
Itself

◆ assign() [3/3]

TimeSpec & sf::TimeSpec::assign ( time_t  sec,
nsec_type  nsec 
)

Assigns seconds and nanoseconds to the current value.

Parameters
secSeconds
nsecNanosecond
Returns
Itself.

◆ clear()

void sf::TimeSpec::clear ( )
inline

clear this instance.

◆ isZero()

bool sf::TimeSpec::isZero ( ) const
inline

Test if it has been set and thus not-zero.

◆ operator bool()

sf::TimeSpec::operator bool ( ) const
inlineexplicit

Test if it has been set and thus not-zero.

◆ operator!=()

bool sf::TimeSpec::operator!= ( const timespec &  ts) const
inline

Compare operator.

◆ operator+()

TimeSpec sf::TimeSpec::operator+ ( const timespec &  t) const
inline

Operator to add another timespec.

Parameters
tTime increment value.
Returns
Itself

◆ operator+=() [1/2]

TimeSpec & sf::TimeSpec::operator+= ( const timespec &  t)
inline

Operator to add another timespec.

Parameters
tTime increment value.
Returns
Itself

◆ operator+=() [2/2]

TimeSpec & sf::TimeSpec::operator+= ( nsec_type  nsec)
inline

Operator to add nanoseconds.

Parameters
nsecNano seconds increment value.
Returns
Itself

◆ operator-()

TimeSpec sf::TimeSpec::operator- ( const timespec &  t) const
inline

Operator to add another timespec.

Parameters
tTime decrement value.
Returns
Itself

◆ operator-=() [1/2]

TimeSpec & sf::TimeSpec::operator-= ( const timespec &  t)
inline

Operator to subtract another timespec.

Parameters
tTime decrement value.
Returns
Itself

◆ operator-=() [2/2]

TimeSpec & sf::TimeSpec::operator-= ( nsec_type  nsec)
inline

Operator to add nanoseconds.

Parameters
nsecNano seconds decrement value.
Returns
Itself

◆ operator<()

bool sf::TimeSpec::operator< ( const timespec &  ts) const
inline

Compare operator.

◆ operator<=()

bool sf::TimeSpec::operator<= ( const timespec &  ts) const
inline

Compare operator.

◆ operator=() [1/3]

TimeSpec & sf::TimeSpec::operator= ( const timespec &  ts)
inline

Assignment operator using base structure.

Parameters
tsBase structure.
Returns
Itself.

◆ operator=() [2/3]

TimeSpec & sf::TimeSpec::operator= ( const TimeSpec ts)
inline

Assignment operator.

Parameters
tsOther instance.
Returns
Itself.

◆ operator=() [3/3]

TimeSpec & sf::TimeSpec::operator= ( TimeSpec &&  )
default

Move assignment operator is default.

◆ operator==()

bool sf::TimeSpec::operator== ( const timespec &  ts) const
inline

Compare operator.

◆ operator>()

bool sf::TimeSpec::operator> ( const timespec &  ts) const
inline

Compare operator.

◆ operator>=()

bool sf::TimeSpec::operator>= ( const timespec &  ts) const
inline

Compare operator.

◆ randomize()

TimeSpec & sf::TimeSpec::randomize ( double  factor = 0.1)

Modifies the current value using the passed factor where 0.1 is + or - 10%.

Parameters
factorFor randomization where 1 = 100%
Returns
Itself.

◆ setTimeOfDay()

TimeSpec & sf::TimeSpec::setTimeOfDay ( )

assign the current time.

Returns
Itself.

◆ sub()

TimeSpec & sf::TimeSpec::sub ( const timespec &  ts)

Subtracts a timespec base type from the current value.

Parameters
tsBase class.
Returns
Itself

◆ toDouble()

double sf::TimeSpec::toDouble ( ) const

Gets the time value as a double.

Returns
Seconds.

◆ toMilliSecs()

time_t sf::TimeSpec::toMilliSecs ( ) const

Gets the time value as a double.

Returns
Seconds.

◆ toString()

std::string sf::TimeSpec::toString ( ) const

Returns the time as toDouble() result converted to a string.

Returns
String

The documentation for this struct was generated from the following file: