Gazebo Transport

API Reference

8.5.0
gz/transport/log/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 
29 namespace ignition
30 {
31  namespace transport
32  {
33  namespace log
34  {
35  // Inline bracket to help doxygen filtering.
36  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
37  //
38  // Forward declarations
39  class PlaybackHandle;
41 
47  class IGNITION_TRANSPORT_LOG_VISIBLE Playback
48  {
52  public: explicit Playback(const std::string &_file,
53  const NodeOptions &_nodeOptions = NodeOptions());
54 
57  public: Playback(Playback &&_old); // NOLINT
58 
60  public: ~Playback();
61 
88  public: [[nodiscard]] PlaybackHandlePtr Start(
89  const std::chrono::nanoseconds &_waitAfterAdvertising =
90  std::chrono::seconds(1)) const;
91 
122  public: [[nodiscard]] PlaybackHandlePtr Start(
123  const std::chrono::nanoseconds &_waitAfterAdvertising,
124  bool _msgWaiting) const;
125 
128  public: bool Valid() const;
129 
136  public: bool AddTopic(const std::string &_topic);
137 
144  public: int64_t AddTopic(const std::regex &_topic);
145 
155  public: bool RemoveTopic(const std::string &_topic);
156 
167  public: int64_t RemoveTopic(const std::regex &_topic);
168 
170  private: class Implementation;
171 
172 #ifdef _WIN32
173 // Disable warning C4251 which is triggered by
174 // std::*
175 #pragma warning(push)
176 #pragma warning(disable: 4251)
177 #endif
178  private: std::unique_ptr<Implementation> dataPtr;
180 #ifdef _WIN32
181 #pragma warning(pop)
182 #endif
183  };
184 
193  class IGNITION_TRANSPORT_LOG_VISIBLE PlaybackHandle
194  {
196  public: void Stop();
197 
200  public: void Seek(const std::chrono::nanoseconds &_newElapsedTime);
201 
205  public: void Step(const std::chrono::nanoseconds &_stepDuration);
206 
208  public: void Pause();
209 
211  public: void Resume();
212 
214  public: bool IsPaused() const;
215 
217  public: void WaitUntilFinished();
218 
221  public: bool Finished() const;
222 
225  public: std::chrono::nanoseconds StartTime() const;
226 
229  public: std::chrono::nanoseconds CurrentTime() const;
230 
233  public: std::chrono::nanoseconds EndTime() const;
234 
236  public: ~PlaybackHandle();
237 
238  // Friendship
239  friend class Playback;
240 
241  // Forward declaration of implementation class
242  private: class Implementation;
243 
245  private: PlaybackHandle(
246  std::unique_ptr<Implementation> &&_internal); // NOLINT
247 
248 #ifdef _WIN32
249 // Disable warning C4251 which is triggered by
250 // std::*
251 #pragma warning(push)
252 #pragma warning(disable: 4251)
253 #endif
254  private: std::unique_ptr<Implementation> dataPtr;
256 #ifdef _WIN32
257 #pragma warning(pop)
258 #endif
259  };
260  }
261  }
262  }
263 }
264 #endif
Definition: gz/transport/AdvertiseOptions.hh:28
STL class.
STL class.
T log(T... args)
A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name.
Definition: gz/transport/NodeOptions.hh:40
Handles the playback of ignition transport topics. This class allows you to manage a log playback onc...
Definition: gz/transport/log/Playback.hh:193
Initiates playback of ignition transport topics This class makes it easy to play topics from a log fi...
Definition: gz/transport/log/Playback.hh:47