Main Page
Classes
Class List
Class Hierarchy
Class Members
All
a
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
w
~
Functions
a
c
d
e
f
g
i
k
l
o
p
r
s
t
u
w
~
Variables
a
c
d
l
m
n
o
p
r
s
t
Typedefs
Files
File List
File Members
All
Functions
src
time_pa.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
* *
3
* time_pa.cpp *
4
* =========== *
5
* *
6
*******************************************************************************
7
* *
8
* Repository: *
9
* https://github.com/TUC-ProAut/ros_octomap *
10
* *
11
* Chair of Automation Technology, Technische Universität Chemnitz *
12
* https://www.tu-chemnitz.de/etit/proaut *
13
* *
14
* Author: *
15
* Peter Weissig *
16
* *
17
*******************************************************************************
18
* *
19
* New BSD License *
20
* *
21
* Copyright (c) 2015-2021 TU Chemnitz *
22
* All rights reserved. *
23
* *
24
* Redistribution and use in source and binary forms, with or without *
25
* modification, are permitted provided that the following conditions are met: *
26
* * Redistributions of source code must retain the above copyright notice, *
27
* this list of conditions and the following disclaimer. *
28
* * Redistributions in binary form must reproduce the above copyright *
29
* notice, this list of conditions and the following disclaimer in the *
30
* documentation and/or other materials provided with the distribution. *
31
* * Neither the name of the copyright holder nor the names of its *
32
* contributors may be used to endorse or promote products derived from *
33
* this software without specific prior written permission. *
34
* *
35
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
36
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
37
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
38
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR *
39
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
40
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
41
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
42
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, *
43
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR *
44
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
45
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
46
* *
47
******************************************************************************/
48
49
// local headers
50
#include "
octomap_pa/time_pa.h
"
51
52
// standard headers
53
#include <cmath>
54
55
56
//**************************[cTimePa]******************************************
57
cTimePa::cTimePa
(
const
int32_t seconds,
const
int32_t nanoseconds):
58
seconds(seconds),nanoseconds(nanoseconds){
59
60
}
61
62
cTimePa::cTimePa
(
const
double
seconds) {
63
64
this->seconds = floor(
seconds
);
65
this->
nanoseconds
= round((
seconds
- floor(
seconds
)) * 1e9);
66
67
fix
();
68
}
69
70
cTimePa::cTimePa
(
const
cTimePa
&other): seconds(other.seconds),
71
nanoseconds(other.nanoseconds){
72
73
}
74
75
const
cTimePa
&
cTimePa::operator =
(
const
cTimePa
&other) {
76
77
seconds
= other.
seconds
;
78
nanoseconds
= other.
nanoseconds
;
79
return
*
this
;
80
}
81
82
bool
cTimePa::operator ==
(
const
cTimePa
&other)
const
{
83
84
return
(
seconds
== other.
seconds
) && (
nanoseconds
== other.
nanoseconds
);
85
}
86
87
bool
cTimePa::operator <
(
const
cTimePa
&other)
const
{
88
89
return
(
seconds
< other.
seconds
) ||
90
((
seconds
== other.
seconds
) && (
nanoseconds
< other.
nanoseconds
));
91
}
92
93
bool
cTimePa::operator >
(
const
cTimePa
&other)
const
{
94
95
return
(
seconds
> other.
seconds
) ||
96
((
seconds
== other.
seconds
) && (
nanoseconds
> other.
nanoseconds
));
97
}
98
99
cTimePa
cTimePa::operator -
(
const
cTimePa
&other) {
100
101
cTimePa
result(
seconds
,
nanoseconds
);
102
result.
seconds
-= other.
seconds
;
103
result.
nanoseconds
-= other.
nanoseconds
;
104
105
result.
fix
();
106
return
result;
107
}
108
109
cTimePa
cTimePa::operator +
(
const
cTimePa
&other) {
110
111
cTimePa
result(
seconds
,
nanoseconds
);
112
result.
seconds
+= other.
seconds
;
113
result.
nanoseconds
+= other.
nanoseconds
;
114
115
result.
fix
();
116
return
result;
117
}
118
119
void
cTimePa::fix
(
void
) {
120
121
seconds
+=
nanoseconds
/ 1000000000;
122
nanoseconds
%= 1000000000;
123
124
if
(
nanoseconds
< 0) {
125
seconds
--;
126
nanoseconds
+= 1000000000;
127
}
128
}
cTimePa::operator==
bool operator==(const cTimePa &other) const
Definition:
time_pa.cpp:82
cTimePa::fix
void fix(void)
Definition:
time_pa.cpp:119
cTimePa::nanoseconds
int32_t nanoseconds
Definition:
time_pa.h:121
cTimePa::operator>
bool operator>(const cTimePa &other) const
Definition:
time_pa.cpp:93
cTimePa::operator+
cTimePa operator+(const cTimePa &other)
Definition:
time_pa.cpp:109
cTimePa::operator<
bool operator<(const cTimePa &other) const
Definition:
time_pa.cpp:87
cTimePa::seconds
int32_t seconds
Definition:
time_pa.h:120
cTimePa::cTimePa
cTimePa(const int32_t seconds=0, const int32_t nanoseconds=0)
Definition:
time_pa.cpp:57
time_pa.h
cTimePa::operator-
cTimePa operator-(const cTimePa &other)
Definition:
time_pa.cpp:99
cTimePa::operator=
const cTimePa & operator=(const cTimePa &other)
Definition:
time_pa.cpp:75
cTimePa
Definition:
time_pa.h:57
octomap_pa
Author(s):
autogenerated on Wed Mar 2 2022 00:46:31