All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LogPlay.hh
Go to the documentation of this file.
1 /*
2  * Copyright 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 
18 #ifndef _LOGPLAY_HH_
19 #define _LOGPLAY_HH_
20 
21 #include <tinyxml.h>
22 
23 #include <list>
24 #include <string>
25 #include <fstream>
26 
27 #include "common/SingletonT.hh"
28 
29 namespace gazebo
30 {
31  namespace common
32  {
35 
46  class LogPlay : public SingletonT<LogPlay>
47  {
49  private: LogPlay();
50 
52  private: virtual ~LogPlay();
53 
59  public: void Open(const std::string &_logFile);
60 
63  public: bool IsOpen() const;
64 
68  public: std::string GetLogVersion() const;
69 
73  public: std::string GetGazeboVersion() const;
74 
78  public: uint32_t GetRandSeed() const;
79 
82  public: bool Step(std::string &_data);
83 
86  public: unsigned int GetChunkCount() const;
87 
92  public: bool GetChunk(unsigned int _index, std::string &_data);
93 
98  public: std::string GetEncoding() const;
99 
104  private: bool GetChunkData(TiXmlElement *_xml, std::string &_data);
105 
107  private: void ReadHeader();
108 
110  private: TiXmlDocument xmlDoc;
111 
113  private: TiXmlElement *logStartXml;
114 
116  private: TiXmlElement *logCurrXml;
117 
119  private: std::string filename;
120 
123  private: std::string logVersion;
124 
126  private: std::string gazeboVersion;
127 
129  private: uint32_t randSeed;
130 
132  private: std::string encoding;
133 
135  private: friend class SingletonT<LogPlay>;
136  };
138  }
139 }
140 
141 #endif