Gazebo Transport

API Reference

14.1.0
Playback.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 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_LOG_PLAYBACK_HH_
18#define GZ_TRANSPORT_LOG_PLAYBACK_HH_
19
20#include <chrono>
21#include <memory>
22#include <regex>
23#include <string>
24
25#include <gz/transport/config.hh>
26#include <gz/transport/log/Export.hh>
28
29namespace gz::transport::log
30{
31 // Inline bracket to help doxygen filtering.
32 inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
33 //
34 // Forward declarations
35 class PlaybackHandle;
37
43 class GZ_TRANSPORT_LOG_VISIBLE Playback
44 {
48 public: explicit Playback(const std::string &_file,
49 const NodeOptions &_nodeOptions = NodeOptions());
50
53 public: Playback(Playback &&_old); // NOLINT
54
56 public: ~Playback();
57
87 public: [[nodiscard]] PlaybackHandlePtr Start(
88 const std::chrono::nanoseconds &_waitAfterAdvertising =
90 bool _msgWaiting = true) const;
91
94 public: bool Valid() const;
95
102 public: bool AddTopic(const std::string &_topic);
103
110 public: int64_t AddTopic(const std::regex &_topic);
111
121 public: bool RemoveTopic(const std::string &_topic);
122
133 public: int64_t RemoveTopic(const std::regex &_topic);
134
136 private: class Implementation;
137
138#ifdef _WIN32
139// Disable warning C4251 which is triggered by
140// std::*
141#pragma warning(push)
142#pragma warning(disable: 4251)
143#endif
145 private: std::unique_ptr<Implementation> dataPtr;
146#ifdef _WIN32
147#pragma warning(pop)
148#endif
149 };
150
159 class GZ_TRANSPORT_LOG_VISIBLE PlaybackHandle
160 {
162 public: void Stop();
163
166 public: void Seek(const std::chrono::nanoseconds &_newElapsedTime);
167
171 public: void Step(const std::chrono::nanoseconds &_stepDuration);
172
174 public: void Pause();
175
177 public: void Resume();
178
180 public: bool IsPaused() const;
181
183 public: void WaitUntilFinished();
184
187 public: bool Finished() const;
188
192
196
200
203
204 // Friendship
205 friend class Playback;
206
207 // Forward declaration of implementation class
208 private: class Implementation;
209
211 private: PlaybackHandle(
212 std::unique_ptr<Implementation> &&_internal); // NOLINT
213
214#ifdef _WIN32
215// Disable warning C4251 which is triggered by
216// std::*
217#pragma warning(push)
218#pragma warning(disable: 4251)
219#endif
221 private: std::unique_ptr<Implementation> dataPtr;
222#ifdef _WIN32
223#pragma warning(pop)
224#endif
225 };
226 }
227}
228#endif