Ignition Transport

API Reference

8.0.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 IGNITION_TRANSPORT_LOG_PLAYBACK_HH_
18 #define IGNITION_TRANSPORT_LOG_PLAYBACK_HH_
19 
20 #include <chrono>
21 #include <memory>
22 #include <regex>
23 #include <string>
24 
25 #include <ignition/transport/config.hh>
26 #include <ignition/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  {
51  public: explicit Playback(const std::string &_file,
52  const NodeOptions &_nodeOptions = NodeOptions());
53 
56  public: Playback(Playback &&_old); // NOLINT
57 
59  public: ~Playback();
60 
87  public: [[nodiscard]] PlaybackHandlePtr Start(
88  const std::chrono::nanoseconds &_waitAfterAdvertising =
89  std::chrono::seconds(1)) const;
90 
121  public: [[nodiscard]] PlaybackHandlePtr Start(
122  const std::chrono::nanoseconds &_waitAfterAdvertising,
123  bool _msgWaiting) const;
124 
127  public: bool Valid() const;
128 
135  public: bool AddTopic(const std::string &_topic);
136 
143  public: int64_t AddTopic(const std::regex &_topic);
144 
154  public: bool RemoveTopic(const std::string &_topic);
155 
166  public: int64_t RemoveTopic(const std::regex &_topic);
167 
169  private: class Implementation;
170 
171 #ifdef _WIN32
172 // Disable warning C4251 which is triggered by
173 // std::*
174 #pragma warning(push)
175 #pragma warning(disable: 4251)
176 #endif
177  private: std::unique_ptr<Implementation> dataPtr;
179 #ifdef _WIN32
180 #pragma warning(pop)
181 #endif
182  };
183 
192  class IGNITION_TRANSPORT_LOG_VISIBLE PlaybackHandle
193  {
195  public: void Stop();
196 
199  public: void Seek(const std::chrono::nanoseconds &_newElapsedTime);
200 
204  public: void Step(const std::chrono::nanoseconds &_stepDuration);
205 
207  public: void Pause();
208 
210  public: void Resume();
211 
213  public: bool IsPaused() const;
214 
216  public: void WaitUntilFinished();
217 
220  public: bool Finished() const;
221 
224  public: std::chrono::nanoseconds StartTime() const;
225 
228  public: std::chrono::nanoseconds CurrentTime() const;
229 
232  public: std::chrono::nanoseconds EndTime() const;
233 
235  public: ~PlaybackHandle();
236 
237  // Friendship
238  friend class Playback;
239 
240  // Forward declaration of implementation class
241  private: class Implementation;
242 
244  private: PlaybackHandle(
245  std::unique_ptr<Implementation> &&_internal); // NOLINT
246 
247 #ifdef _WIN32
248 // Disable warning C4251 which is triggered by
249 // std::*
250 #pragma warning(push)
251 #pragma warning(disable: 4251)
252 #endif
253  private: std::unique_ptr<Implementation> dataPtr;
255 #ifdef _WIN32
256 #pragma warning(pop)
257 #endif
258  };
259  }
260  }
261  }
262 }
263 #endif
A class for customizing the behavior of the Node. E.g.: Set a custom namespace or a partition name...
Definition: NodeOptions.hh:40
T log(T... args)
Initiates playback of ignition transport topics This class makes it easy to play topics from a log fi...
Definition: Playback.hh:47
Handles the playback of ignition transport topics. This class allows you to manage a log playback onc...
Definition: Playback.hh:192
STL class.
Definition: AdvertiseOptions.hh:28