LogPlay.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 
28 GZ_SINGLETON_DECLARE(GZ_UTIL_VISIBLE, gazebo, util, LogPlay)
29 
30 namespace gazebo
31 {
32  namespace util
33  {
34  // Forward declare private data class
35  class LogPlayPrivate;
36 
39 
50  class GZ_UTIL_VISIBLE LogPlay : public SingletonT<LogPlay>
51  {
53  private: LogPlay();
54 
56  private: virtual ~LogPlay();
57 
64  public: void Open(const std::string &_logFile);
65 
68  public: bool IsOpen() const;
69 
73  public: std::string LogVersion() const;
74 
78  public: std::string GazeboVersion() const;
79 
83  public: uint32_t RandSeed() const;
84 
87  public: common::Time LogStartTime() const;
88 
91  public: common::Time LogEndTime() const;
92 
95  public: std::string Filename() const;
96 
99  public: std::string FullPathFilename() const;
100 
103  public: uintmax_t FileSize() const;
104 
107  public: bool Step(std::string &_data);
108 
111  public: bool StepBack(std::string &_data);
112 
116  public: bool Step(const int _step, std::string &_data);
117 
122  public: bool Seek(const common::Time &_time);
123 
127  public: bool Rewind();
128 
131  public: bool Forward();
132 
135  public: unsigned int ChunkCount() const;
136 
141  public: bool Chunk(const unsigned int _index, std::string &_data) const;
142 
147  public: std::string Encoding() const;
148 
152  public: std::string Header() const;
153 
156  public: uint64_t InitialIterations() const;
157 
162  public: bool HasIterations() const;
163 
165  private: void ReadHeader();
166 
169  private: void ReadLogTimes();
170 
175  private: bool ReadIterations();
176 
180  private: bool NextChunk();
181 
185  private: bool PrevChunk();
186 
189  private: std::unique_ptr<LogPlayPrivate> dataPtr;
190 
192  private: friend class SingletonT<LogPlay>;
193  };
195  }
196 }
197 
198 #endif
Forward declarations for the common classes.
Definition: Animation.hh:26
Singleton template class.
Definition: SingletonT.hh:33
util
Definition: LogPlay.hh:28
Definition: LogPlay.hh:50
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:47