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 <memory>
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 
70  public: std::string LogVersion() const;
71 
75  public: std::string GazeboVersion() const;
76 
80  public: uint32_t RandSeed() const;
81 
84  public: common::Time LogStartTime() const;
85 
88  public: common::Time LogEndTime() const;
89 
92  public: std::string Filename() const;
93 
96  public: std::string FullPathFilename() const;
97 
100  public: uintmax_t FileSize() const;
101 
104  public: bool Step(std::string &_data);
105 
108  public: bool StepBack(std::string &_data);
109 
113  public: bool Step(const int _step, std::string &_data);
114 
119  public: bool Seek(const common::Time &_time);
120 
124  public: bool Rewind();
125 
128  public: bool Forward();
129 
132  public: unsigned int ChunkCount() const;
133 
138  public: bool Chunk(const unsigned int _index, std::string &_data) const;
139 
144  public: std::string Encoding() const;
145 
149  public: std::string Header() const;
150 
153  public: uint64_t InitialIterations() const;
154 
159  public: bool HasIterations() const;
160 
162  private: void ReadHeader();
163 
166  private: void ReadLogTimes();
167 
172  private: bool ReadIterations();
173 
177  private: bool NextChunk();
178 
182  private: bool PrevChunk();
183 
186  private: std::unique_ptr<LogPlayPrivate> dataPtr;
187 
189  private: friend class SingletonT<LogPlay>;
190  };
192  }
193 }
194 
195 #endif
Singleton template class.
Definition: SingletonT.hh:33
Definition: LogPlay.hh:47
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44