LogPlay.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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_LOGPLAY_HH_
18 #define _GAZEBO_LOGPLAY_HH_
19 
20 #include <tinyxml.h>
21 
22 #include <list>
23 #include <mutex>
24 #include <string>
25 
27 #include "gazebo/common/Time.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace util
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 
70  public: std::string GetLogVersion() const;
71 
75  public: std::string GetGazeboVersion() const;
76 
80  public: uint32_t GetRandSeed() const;
81 
84  public: common::Time GetLogStartTime() const;
85 
88  public: common::Time GetLogEndTime() const;
89 
92  public: std::string GetFilename() const;
93 
96  public: std::string GetFullPathFilename() const;
97 
100  public: uintmax_t GetFileSize() const;
101 
104  public: bool Step(std::string &_data);
105 
109  public: bool Rewind();
110 
113  public: unsigned int GetChunkCount() const;
114 
119  public: bool GetChunk(unsigned int _index, std::string &_data);
120 
125  public: std::string GetEncoding() const;
126 
130  public: std::string GetHeader() const;
131 
134  public: uint64_t GetInitialIterations() const;
135 
140  public: bool HasIterations() const;
141 
146  private: bool GetChunkData(TiXmlElement *_xml, std::string &_data);
147 
149  private: void ReadHeader();
150 
153  private: void ReadLogTimes();
154 
157  private: bool ReadIterations();
158 
160  private: TiXmlDocument xmlDoc;
161 
163  private: TiXmlElement *logStartXml;
164 
166  private: TiXmlElement *logCurrXml;
167 
169  private: std::string filename;
170 
173  private: std::string logVersion;
174 
176  private: std::string gazeboVersion;
177 
179  private: uint32_t randSeed;
180 
182  private: common::Time logStartTime;
183 
185  private: common::Time logEndTime;
186 
188  private: std::string encoding;
189 
190  private: std::string currentChunk;
191 
193  private: uint64_t initialIterations;
194 
197  private: bool iterationsFound;
198 
200  private: std::mutex mutex;
201 
203  private: friend class SingletonT<LogPlay>;
204  };
206  }
207 }
208 
209 #endif
GAZEBO_VISIBLE msgs::Header * GetHeader(google::protobuf::Message &_message)
Get the header from a protobuf message.
Singleton template class.
Definition: SingletonT.hh:33
#define GZ_UTIL_VISIBLE
Definition: system.hh:266
Definition: LogPlay.hh:47
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:39