Vector BLF
UncompressedFile.h
1 /*
2  * Copyright (C) 2013 Tobias Lorenz.
3  * Contact: tobias.lorenz@gmx.net
4  *
5  * This file is part of Tobias Lorenz's Toolkit.
6  *
7  * Commercial License Usage
8  * Licensees holding valid commercial licenses may use this file in
9  * accordance with the commercial license agreement provided with the
10  * Software or, alternatively, in accordance with the terms contained in
11  * a written agreement between you and Tobias Lorenz.
12  *
13  * GNU General Public License 3.0 Usage
14  * Alternatively, this file may be used under the terms of the GNU
15  * General Public License version 3.0 as published by the Free Software
16  * Foundation and appearing in the file LICENSE.GPL included in the
17  * packaging of this file. Please review the following information to
18  * ensure the GNU General Public License version 3.0 requirements will be
19  * met: http://www.gnu.org/copyleft/gpl.html.
20  */
21 
22 #pragma once
23 
24 #include <Vector/BLF/platform.h>
25 
26 #include <condition_variable>
27 #include <limits>
28 #include <list>
29 #include <memory>
30 #include <mutex>
31 
32 #include <Vector/BLF/AbstractFile.h>
33 #include <Vector/BLF/LogContainer.h>
34 
35 #include <Vector/BLF/vector_blf_export.h>
36 
37 namespace Vector {
38 namespace BLF {
39 
53 class VECTOR_BLF_EXPORT UncompressedFile final : public AbstractFile {
54  public:
55  UncompressedFile() = default;
56  ~UncompressedFile() override;
57 
58  std::streamsize gcount() const override;
59  void read(char * s, std::streamsize n) override;
60  std::streampos tellg() override;
61  void seekg(std::streamoff off, const std::ios_base::seekdir way = std::ios_base::cur) override;
62  void write(const char * s, std::streamsize n) override;
63  std::streampos tellp() override;
64  bool good() const override;
65  bool eof() const override;
66 
70  virtual void abort();
71 
77  virtual void write(const std::shared_ptr<LogContainer> & logContainer);
78 
82  virtual void nextLogContainer();
83 
89  virtual std::streamsize fileSize() const;
90 
96  virtual void setFileSize(std::streamsize fileSize);
97 
104  virtual void setBufferSize(std::streamsize bufferSize);
105 
109  virtual void dropOldData();
110 
116  virtual DWORD defaultLogContainerSize() const;
117 
123  virtual void setDefaultLogContainerSize(DWORD defaultLogContainerSize);
124 
126  std::condition_variable tellgChanged;
127 
129  std::condition_variable tellpChanged;
130 
131  private:
133  bool m_abort {};
134 
136  std::list<std::shared_ptr<LogContainer>> m_data {};
137 
139  std::streampos m_tellg {};
140 
142  std::streampos m_tellp {};
143 
145  std::streamsize m_gcount {};
146 
148  std::streamsize m_fileSize {std::numeric_limits<std::streamsize>::max()};
149 
151  std::streamsize m_bufferSize {std::numeric_limits<std::streamsize>::max()};
152 
154  std::ios_base::iostate m_rdstate {std::ios_base::goodbit};
155 
157  mutable std::mutex m_mutex {};
158 
160  DWORD m_defaultLogContainerSize {0x20000};
161 
172  std::shared_ptr<LogContainer> logContainerContaining(std::streampos pos);
173 };
174 
175 }
176 }
Definition: UncompressedFile.h:53
std::condition_variable tellpChanged
Definition: UncompressedFile.h:129
std::condition_variable tellgChanged
Definition: UncompressedFile.h:126
Definition: AbstractFile.h:36