Gazebo Transport
API Reference
15.0.0~pre1
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-transport
include
gz
transport
Clock.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_TRANSPORT_CLOCK_HH_
18
#define GZ_TRANSPORT_CLOCK_HH_
19
20
#include <chrono>
21
#include <memory>
22
#include <string>
23
24
#include <gz/utils/SuppressWarning.hh>
25
26
#include "gz/transport/config.hh"
27
#include "gz/transport/Export.hh"
28
29
namespace
gz::transport
30
{
31
// Inline bracket to help doxygen filtering.
32
inline
namespace
GZ_TRANSPORT_VERSION_NAMESPACE {
33
//
36
class
GZ_TRANSPORT_VISIBLE
Clock
37
{
40
public
:
virtual
std::chrono::nanoseconds
Time
()
const
= 0;
41
44
public
:
virtual
bool
IsReady
()
const
= 0;
45
47
public
:
virtual
~Clock
() =
default
;
48
};
49
54
class
GZ_TRANSPORT_VISIBLE
NetworkClock
:
public
Clock
55
{
57
public
:
enum class
TimeBase
: int64_t
58
{
59
REAL,
60
SIM,
61
SYS
62
};
63
69
public
:
explicit
NetworkClock
(
const
std::string
&_topicName,
70
const
TimeBase
_timeBase = TimeBase::SIM);
71
73
public
:
~NetworkClock
()
override
;
74
75
// Documentation inherited
76
public
:
std::chrono::nanoseconds
Time
()
const override
;
77
81
public
:
void
SetTime
(
const
std::chrono::nanoseconds
_time);
82
83
// Documentation inherited
84
public
:
bool
IsReady
()
const override
;
85
87
private
:
class
Implementation;
88
90
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
91
private
:
std::unique_ptr<Implementation>
dataPtr;
92
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
93
};
94
97
class
GZ_TRANSPORT_VISIBLE
WallClock
:
public
Clock
98
{
101
public
:
static
WallClock
*
Instance
();
102
103
// Documentation inherited
104
public
:
std::chrono::nanoseconds
Time
()
const override
;
105
106
// Documentation inherited
107
public
:
bool
IsReady
()
const override
;
108
110
private
:
WallClock
();
111
113
private
:
~WallClock
()
override
;
114
116
private
:
class
Implementation;
117
119
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
120
private
:
std::unique_ptr<Implementation>
dataPtr;
121
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
122
};
123
}
124
}
125
126
#endif