Gazebo Transport

API Reference

11.4.1
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 
30 {
31  // Inline bracket to help doxygen filtering.
32  inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
33  //
34  // Forward declarations
35  class PlaybackHandle;
37 
43  class IGNITION_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
144  private: std::unique_ptr<Implementation> dataPtr;
146 #ifdef _WIN32
147 #pragma warning(pop)
148 #endif
149  };
150 
159  class IGNITION_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 
191  public: std::chrono::nanoseconds StartTime() const;
192 
195  public: std::chrono::nanoseconds CurrentTime() const;
196 
199  public: std::chrono::nanoseconds EndTime() const;
200 
202  public: ~PlaybackHandle();
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
220  private: std::unique_ptr<Implementation> dataPtr;
222 #ifdef _WIN32
223 #pragma warning(pop)
224 #endif
225  };
226  }
227 }
228 #endif
STL class.
STL class.
A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name.
Definition: gz/transport/NodeOptions.hh:38
Handles the playback of ignition transport topics. This class allows you to manage a log playback onc...
Definition: gz/transport/log/Playback.hh:159
Initiates playback of ignition transport topics This class makes it easy to play topics from a log fi...
Definition: gz/transport/log/Playback.hh:43
Definition: gz/transport/log/Batch.hh:27