Ignition Transport

API Reference

10.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 
90  public: [[nodiscard]] PlaybackHandlePtr Start(
91  const std::chrono::nanoseconds &_waitAfterAdvertising =
93  bool _msgWaiting = true) const;
94 
97  public: bool Valid() const;
98 
105  public: bool AddTopic(const std::string &_topic);
106 
113  public: int64_t AddTopic(const std::regex &_topic);
114 
124  public: bool RemoveTopic(const std::string &_topic);
125 
136  public: int64_t RemoveTopic(const std::regex &_topic);
137 
139  private: class Implementation;
140 
141 #ifdef _WIN32
142 // Disable warning C4251 which is triggered by
143 // std::*
144 #pragma warning(push)
145 #pragma warning(disable: 4251)
146 #endif
147  private: std::unique_ptr<Implementation> dataPtr;
149 #ifdef _WIN32
150 #pragma warning(pop)
151 #endif
152  };
153 
162  class IGNITION_TRANSPORT_LOG_VISIBLE PlaybackHandle
163  {
165  public: void Stop();
166 
169  public: void Seek(const std::chrono::nanoseconds &_newElapsedTime);
170 
174  public: void Step(const std::chrono::nanoseconds &_stepDuration);
175 
177  public: void Pause();
178 
180  public: void Resume();
181 
183  public: bool IsPaused() const;
184 
186  public: void WaitUntilFinished();
187 
190  public: bool Finished() const;
191 
194  public: std::chrono::nanoseconds StartTime() const;
195 
198  public: std::chrono::nanoseconds CurrentTime() const;
199 
202  public: std::chrono::nanoseconds EndTime() const;
203 
205  public: ~PlaybackHandle();
206 
207  // Friendship
208  friend class Playback;
209 
210  // Forward declaration of implementation class
211  private: class Implementation;
212 
214  private: PlaybackHandle(
215  std::unique_ptr<Implementation> &&_internal); // NOLINT
216 
217 #ifdef _WIN32
218 // Disable warning C4251 which is triggered by
219 // std::*
220 #pragma warning(push)
221 #pragma warning(disable: 4251)
222 #endif
223  private: std::unique_ptr<Implementation> dataPtr;
225 #ifdef _WIN32
226 #pragma warning(pop)
227 #endif
228  };
229  }
230  }
231  }
232 }
233 #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:162
STL class.
Definition: AdvertiseOptions.hh:28