Ignition Transport

API Reference

11.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  {
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 
91  public: [[nodiscard]] PlaybackHandlePtr Start(
92  const std::chrono::nanoseconds &_waitAfterAdvertising =
94  bool _msgWaiting = true) const;
95 
98  public: bool Valid() const;
99 
106  public: bool AddTopic(const std::string &_topic);
107 
114  public: int64_t AddTopic(const std::regex &_topic);
115 
125  public: bool RemoveTopic(const std::string &_topic);
126 
137  public: int64_t RemoveTopic(const std::regex &_topic);
138 
140  private: class Implementation;
141 
142 #ifdef _WIN32
143 // Disable warning C4251 which is triggered by
144 // std::*
145 #pragma warning(push)
146 #pragma warning(disable: 4251)
147 #endif
148  private: std::unique_ptr<Implementation> dataPtr;
150 #ifdef _WIN32
151 #pragma warning(pop)
152 #endif
153  };
154 
163  class IGNITION_TRANSPORT_LOG_VISIBLE PlaybackHandle
164  {
166  public: void Stop();
167 
170  public: void Seek(const std::chrono::nanoseconds &_newElapsedTime);
171 
175  public: void Step(const std::chrono::nanoseconds &_stepDuration);
176 
178  public: void Pause();
179 
181  public: void Resume();
182 
184  public: bool IsPaused() const;
185 
187  public: void WaitUntilFinished();
188 
191  public: bool Finished() const;
192 
195  public: std::chrono::nanoseconds StartTime() const;
196 
199  public: std::chrono::nanoseconds CurrentTime() const;
200 
203  public: std::chrono::nanoseconds EndTime() const;
204 
206  public: ~PlaybackHandle();
207 
208  // Friendship
209  friend class Playback;
210 
211  // Forward declaration of implementation class
212  private: class Implementation;
213 
215  private: PlaybackHandle(
216  std::unique_ptr<Implementation> &&_internal); // NOLINT
217 
218 #ifdef _WIN32
219 // Disable warning C4251 which is triggered by
220 // std::*
221 #pragma warning(push)
222 #pragma warning(disable: 4251)
223 #endif
224  private: std::unique_ptr<Implementation> dataPtr;
226 #ifdef _WIN32
227 #pragma warning(pop)
228 #endif
229  };
230  }
231  }
232  }
233 }
234 #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:163
STL class.
Definition: AdvertiseOptions.hh:28