Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JTimeval Class Reference

Auxiliary class for time values. More...

#include <JTimeval.hh>

Inheritance diagram for JLANG::JTimeval:
JLANG::JComparable< JTimeval > JNET::JControlHostObjectIterator< T >

Public Member Functions

 JTimeval ()
 Default constructor.
 
 JTimeval (const int tv_us)
 Constructor.
 
 JTimeval (const int tv_s, const int tv_us)
 Constructor.
 
const JTimevalgetTimeval () const
 Get time value.
 
JTimevalgetTimeval ()
 Get time value.
 
void setTimeval (const JTimeval &timeval)
 Set time value.
 
bool less (const JTimeval &value) const
 Less than method.
 
const timeval * get () const
 Get pointer to time value.
 
timeval * get ()
 Get pointer to time value.
 
const timeval * operator& () const
 Address of operator.
 
timeval * operator& ()
 Address of operator.
 

Static Public Member Functions

static JTimeval min ()
 Get minimal time value.
 
static JTimeval max ()
 Get maximal time value.
 

Friends

std::istream & operator>> (std::istream &in, JTimeval &time)
 Read time value from input.
 
std::ostream & operator<< (std::ostream &out, const JTimeval &time)
 Write time value to output.
 

Detailed Description

Auxiliary class for time values.

This class encapsulates the timeval data structure.

Definition at line 26 of file JTimeval.hh.

Constructor & Destructor Documentation

◆ JTimeval() [1/3]

JLANG::JTimeval::JTimeval ( )
inline

Default constructor.

Definition at line 34 of file JTimeval.hh.

35 {
36 this->tv_sec = 0;
37 this->tv_usec = 0;
38 }

◆ JTimeval() [2/3]

JLANG::JTimeval::JTimeval ( const int tv_us)
inline

Constructor.

Parameters
tv_ustime [us]

Definition at line 46 of file JTimeval.hh.

47 {
48 this->tv_sec = 0;
49 this->tv_usec = tv_us;
50 }

◆ JTimeval() [3/3]

JLANG::JTimeval::JTimeval ( const int tv_s,
const int tv_us )
inline

Constructor.

Parameters
tv_stime [s]
tv_ustime [us]

Definition at line 59 of file JTimeval.hh.

60 {
61 this->tv_sec = tv_s;
62 this->tv_usec = tv_us;
63 }

Member Function Documentation

◆ getTimeval() [1/2]

const JTimeval & JLANG::JTimeval::getTimeval ( ) const
inline

Get time value.

Returns
time value

Definition at line 71 of file JTimeval.hh.

72 {
73 return static_cast<const JTimeval&>(*this);
74 }
JTimeval()
Default constructor.
Definition JTimeval.hh:34

◆ getTimeval() [2/2]

JTimeval & JLANG::JTimeval::getTimeval ( )
inline

Get time value.

Returns
time value

Definition at line 82 of file JTimeval.hh.

83 {
84 return static_cast<JTimeval&>(*this);
85 }

◆ setTimeval()

void JLANG::JTimeval::setTimeval ( const JTimeval & timeval)
inline

Set time value.

Parameters
timevaltime value

Definition at line 93 of file JTimeval.hh.

94 {
95 static_cast<JTimeval&>(*this) = timeval;
96 }

◆ less()

bool JLANG::JTimeval::less ( const JTimeval & value) const
inline

Less than method.

Parameters
valuetime value
Returns
true if this time value less than given time value; else false

Definition at line 105 of file JTimeval.hh.

106 {
107 if (this->tv_sec == value.tv_sec)
108 return this->tv_usec < value.tv_usec;
109 else
110 return this->tv_sec < value.tv_sec;
111 }

◆ min()

static JTimeval JLANG::JTimeval::min ( )
inlinestatic

Get minimal time value.

Returns
time value

Definition at line 119 of file JTimeval.hh.

120 {
121 return JTimeval(0, 0);
122 }

◆ max()

static JTimeval JLANG::JTimeval::max ( )
inlinestatic

Get maximal time value.

Returns
time value

Definition at line 131 of file JTimeval.hh.

132 {
133 return JTimeval(std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
134 }

◆ get() [1/2]

const timeval * JLANG::JTimeval::get ( ) const
inline

Get pointer to time value.

Returns
pointer to time value

Definition at line 143 of file JTimeval.hh.

144 {
145 return static_cast<const timeval*>(this);
146 }

◆ get() [2/2]

timeval * JLANG::JTimeval::get ( )
inline

Get pointer to time value.

Returns
pointer to time value

Definition at line 154 of file JTimeval.hh.

155 {
156 return static_cast<timeval*>(this);
157 }

◆ operator&() [1/2]

const timeval * JLANG::JTimeval::operator& ( ) const
inline

Address of operator.

Returns
pointer to time value

Definition at line 165 of file JTimeval.hh.

166 {
167 return get();
168 }
const timeval * get() const
Get pointer to time value.
Definition JTimeval.hh:143

◆ operator&() [2/2]

timeval * JLANG::JTimeval::operator& ( )
inline

Address of operator.

Returns
pointer to time value

Definition at line 176 of file JTimeval.hh.

177 {
178 return get();
179 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JTimeval & time )
friend

Read time value from input.

Parameters
ininput stream
timetime value
Returns
input stream

Definition at line 189 of file JTimeval.hh.

190 {
191 return in >> time.tv_sec >> time.tv_usec;
192 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JTimeval & time )
friend

Write time value to output.

Parameters
outoutput stream
timetime value
Returns
output stream

Definition at line 202 of file JTimeval.hh.

203 {
204 return out << time.tv_sec << ' ' << time.tv_usec;
205 }

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