LogPlay.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 _GAZEBO_UTIL_LOGPLAY_HH_
18 #define _GAZEBO_UTIL_LOGPLAY_HH_
19 
20 #include <tinyxml2.h>
21 #include <string>
22 
24 #include "gazebo/common/Time.hh"
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace util
30  {
31  // Forward declare private data class
32  class LogPlayPrivate;
33 
36 
47  class GZ_UTIL_VISIBLE LogPlay : public SingletonT<LogPlay>
48  {
50  private: LogPlay();
51 
53  private: virtual ~LogPlay();
54 
61  public: void Open(const std::string &_logFile);
62 
65  public: bool IsOpen() const;
66 
71  public: std::string GetLogVersion() const GAZEBO_DEPRECATED(7.0);
72 
76  public: std::string LogVersion() const;
77 
82  public: std::string GetGazeboVersion() const GAZEBO_DEPRECATED(7.0);
83 
87  public: std::string GazeboVersion() const;
88 
93  public: uint32_t GetRandSeed() const GAZEBO_DEPRECATED(7.0);
94 
98  public: uint32_t RandSeed() const;
99 
103  public: common::Time GetLogStartTime() const GAZEBO_DEPRECATED(7.0);
104 
107  public: common::Time LogStartTime() const;
108 
112  public: common::Time GetLogEndTime() const GAZEBO_DEPRECATED(7.0);
113 
116  public: common::Time LogEndTime() const;
117 
121  public: std::string GetFilename() const GAZEBO_DEPRECATED(7.0);
122 
125  public: std::string Filename() const;
126 
130  public: std::string GetFullPathFilename() const GAZEBO_DEPRECATED(7.0);
131 
134  public: std::string FullPathFilename() const;
135 
139  public: uintmax_t GetFileSize() const GAZEBO_DEPRECATED(7.0);
140 
143  public: uintmax_t FileSize() const;
144 
147  public: bool Step(std::string &_data);
148 
151  public: bool StepBack(std::string &_data);
152 
156  public: bool Step(const int _step, std::string &_data);
157 
162  public: bool Seek(const common::Time &_time);
163 
167  public: bool Rewind();
168 
171  public: bool Forward();
172 
176  public: unsigned int GetChunkCount() const GAZEBO_DEPRECATED(7.0);
177 
180  public: unsigned int ChunkCount() const;
181 
187  public: bool GetChunk(unsigned int _index, std::string &_data)
188  GAZEBO_DEPRECATED(7.0);
189 
194  public: bool Chunk(const unsigned int _index, std::string &_data) const;
195 
201  public: std::string GetEncoding() const GAZEBO_DEPRECATED(7.0);
202 
207  public: std::string Encoding() const;
208 
213  public: std::string GetHeader() const GAZEBO_DEPRECATED(7.0);
214 
218  public: std::string Header() const;
219 
223  public: uint64_t GetInitialIterations() const GAZEBO_DEPRECATED(7.0);
224 
227  public: uint64_t InitialIterations() const;
228 
233  public: bool HasIterations() const;
234 
239  private: bool ChunkData(tinyxml2::XMLElement *_xml,
240  std::string &_data) const;
241 
243  private: void ReadHeader();
244 
247  private: void ReadLogTimes();
248 
253  private: bool ReadIterations();
254 
258  private: bool NextChunk();
259 
263  private: bool PrevChunk();
264 
267  private: std::unique_ptr<LogPlayPrivate> dataPtr;
268 
270  private: friend class SingletonT<LogPlay>;
271  };
273  }
274 }
275 
276 #endif
GAZEBO_VISIBLE msgs::Header * GetHeader(google::protobuf::Message &_message)
Get the header from a protobuf message.
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:48
Singleton template class.
Definition: SingletonT.hh:33
#define GZ_UTIL_VISIBLE
Definition: system.hh:234
Definition: LogPlay.hh:47
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44