Auxiliary class for time values.
More...
#include <JTimeval.hh>
|
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.
|
|
Auxiliary class for time values.
This class encapsulates the timeval
data structure.
Definition at line 26 of file JTimeval.hh.
◆ 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
-
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_s | time [s] |
tv_us | time [us] |
Definition at line 59 of file JTimeval.hh.
60 {
61 this->tv_sec = tv_s;
62 this->tv_usec = tv_us;
63 }
◆ 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.
◆ 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
-
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
-
- 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.
◆ 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 {
168 }
const timeval * get() const
Get pointer to time value.
◆ operator&() [2/2]
timeval * JLANG::JTimeval::operator& |
( |
| ) |
|
|
inline |
Address of operator.
- Returns
- pointer to time value
Definition at line 176 of file JTimeval.hh.
◆ operator>>
std::istream & operator>> |
( |
std::istream & | in, |
|
|
JTimeval & | time ) |
|
friend |
Read time value from input.
- Parameters
-
in | input stream |
time | time 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
-
out | output stream |
time | time 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: