pocolog_cpp
LogFile.hpp
Go to the documentation of this file.
1 #ifndef LOGFILE_H
2 #define LOGFILE_H
3 #include <string>
4 #include <vector>
5 #include "Stream.hpp"
6 #include "Format.hpp"
7 #include "FileStream.hpp"
8 
9 namespace pocolog_cpp
10 {
11 
12 class IndexFile;
13 
14 class LogFile
15 {
16  std::vector<char > readBuffer;
17  std::string filename;
18  std::streampos firstBlockHeaderPos;
19  std::streampos nextBlockHeaderPos;
20  std::streampos curBlockHeaderPos;
21  std::streampos curSampleHeaderPos;
22  FileStream logFile;
23  std::vector<IndexFile *> indexFiles;
24 
25  std::vector<Stream *> streams;
26  std::vector<StreamDescription> descriptions;
27 
28  bool gotBlockHeader;
29  struct BlockHeader curBlockHeader;
30  bool gotSampleHeader;
31  struct SampleHeaderData curSampleHeader;
32 
33 public:
34  LogFile(const std::string &fileName);
35  ~LogFile();
36 
37  std::string getFileName() const;
38  std::string getFileBaseName() const;
39 
40  const std::vector<Stream *> &getStreams() const;
41  const std::vector<StreamDescription> &getStreamDescriptions() const;
42 
43  bool loadStreamDescription(StreamDescription &result, std::streampos descPos);
44 
45  const BlockHeader &getCurBlockHeader() const;
46 
47  bool readNextBlockHeader(struct BlockHeader &curBlockHeade);
48  bool readNextBlockHeader();
49  bool readSampleHeader();
50  bool checkSampleComplete();
51 
52  bool readCurBlock(std::vector<uint8_t> &blockData);
53 
54 
55  std::streampos getSamplePos() const;
56  std::streampos getBlockDataPos() const;
57  std::streampos getBlockHeaderPos() const;
58  const base::Time getSampleTime() const;
59  size_t getSampleStreamIdx() const;
60 
61  bool eof() const;
62 
63  Stream &getStream(const std::string streamName) const;
64 
65 };
66 }
67 #endif // LOGFILE_H
~LogFile()
Definition: LogFile.cpp:60
bool checkSampleComplete()
Definition: LogFile.cpp:209
bool readCurBlock(std::vector< uint8_t > &blockData)
Definition: LogFile.cpp:176
bool eof() const
Definition: LogFile.cpp:261
Definition: Format.hpp:122
bool loadStreamDescription(StreamDescription &result, std::streampos descPos)
Definition: LogFile.cpp:91
bool readNextBlockHeader()
Definition: LogFile.cpp:143
Stream & getStream(const std::string streamName) const
Definition: LogFile.cpp:81
const base::Time getSampleTime() const
Definition: LogFile.cpp:252
Definition: Format.hpp:131
bool readSampleHeader()
Definition: LogFile.cpp:184
std::streampos getSamplePos() const
Definition: LogFile.cpp:214
size_t getSampleStreamIdx() const
Definition: LogFile.cpp:243
const std::vector< Stream * > & getStreams() const
Definition: LogFile.cpp:76
LogFile(const std::string &fileName)
Definition: LogFile.cpp:10
const std::vector< StreamDescription > & getStreamDescriptions() const
Definition: LogFile.cpp:117
std::string getFileName() const
Definition: LogFile.cpp:122
Definition: FileStream.hpp:7
Definition: StreamDescription.hpp:13
std::streampos getBlockHeaderPos() const
Definition: LogFile.cpp:234
std::string getFileBaseName() const
Definition: LogFile.cpp:127
const BlockHeader & getCurBlockHeader() const
Definition: LogFile.cpp:171
Definition: FileStream.hpp:22
std::streampos getBlockDataPos() const
Definition: LogFile.cpp:225
Definition: LogFile.hpp:14
Definition: Read.hpp:91