Vector BLF: UncompressedFile.h Source File

Vector BLF

Loading...
Searching...
No Matches
UncompressedFile.h
1// SPDX-FileCopyrightText: 2013-2021 Tobias Lorenz <tobias.lorenz@gmx.net>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7#include <Vector/BLF/platform.h>
8
9#include <condition_variable>
10#include <limits>
11#include <list>
12#include <memory>
13#include <mutex>
14
15#include <Vector/BLF/AbstractFile.h>
16#include <Vector/BLF/LogContainer.h>
17
18#include <Vector/BLF/vector_blf_export.h>
19
20namespace Vector {
21namespace BLF {
22
36 class VECTOR_BLF_EXPORT UncompressedFile final : public AbstractFile {
37 public:
38 UncompressedFile() = default;
39 ~UncompressedFile() override;
40
41 std::streamsize gcount() const override;
42 void read(char * s, std::streamsize n) override;
43 std::streampos tellg() override;
44 void seekg(std::streamoff off, const std::ios_base::seekdir way = std::ios_base::cur) override;
45 void write(const char * s, std::streamsize n) override;
46 std::streampos tellp() override;
47 bool good() const override;
48 bool eof() const override;
49
53 virtual void abort();
54
60 virtual void write(const std::shared_ptr<LogContainer> & logContainer);
61
65 virtual void nextLogContainer();
66
72 virtual std::streamsize fileSize() const;
73
79 virtual void setFileSize(std::streamsize fileSize);
80
87 virtual void setBufferSize(std::streamsize bufferSize);
88
92 virtual void dropOldData();
93
99 virtual uint32_t defaultLogContainerSize() const;
100
106 virtual void setDefaultLogContainerSize(uint32_t defaultLogContainerSize);
107
109 std::condition_variable tellgChanged;
110
112 std::condition_variable tellpChanged;
113
114 private:
116 bool m_abort {};
117
119 std::list<std::shared_ptr<LogContainer>> m_data {};
120
122 std::streampos m_tellg {};
123
125 std::streampos m_tellp {};
126
128 std::streamsize m_gcount {};
129
131 std::streamsize m_fileSize {std::numeric_limits<std::streamsize>::max()};
132
134 std::streamsize m_bufferSize {std::numeric_limits<std::streamsize>::max()};
135
137 std::ios_base::iostate m_rdstate {std::ios_base::goodbit};
138
140 mutable std::mutex m_mutex {};
141
143 uint32_t m_defaultLogContainerSize {0x20000};
144
155 std::shared_ptr<LogContainer> logContainerContaining(const std::streampos pos) const;
156};
157
158}
159}
Vector::BLF::UncompressedFile::gcount
std::streamsize gcount() const override
Definition UncompressedFile.cpp:24
Vector::BLF::UncompressedFile::eof
bool eof() const override
Definition UncompressedFile.cpp:177
Vector::BLF::UncompressedFile::seekg
void seekg(std::streamoff off, const std::ios_base::seekdir way=std::ios_base::cur) override
Definition UncompressedFile.cpp:92
Vector::BLF::UncompressedFile::tellpChanged
std::condition_variable tellpChanged
Definition UncompressedFile.h:112
Vector::BLF::UncompressedFile::good
bool good() const override
Definition UncompressedFile.cpp:170
Vector::BLF::UncompressedFile::setDefaultLogContainerSize
virtual void setDefaultLogContainerSize(uint32_t defaultLogContainerSize)
Definition UncompressedFile.cpp:297
Vector::BLF::UncompressedFile::setFileSize
virtual void setFileSize(std::streamsize fileSize)
Definition UncompressedFile.cpp:250
Vector::BLF::UncompressedFile::write
void write(const char *s, std::streamsize n) override
Definition UncompressedFile.cpp:103
Vector::BLF::UncompressedFile::read
void read(char *s, std::streamsize n) override
Definition UncompressedFile.cpp:31
Vector::BLF::UncompressedFile::tellp
std::streampos tellp() override
Definition UncompressedFile.cpp:160
Vector::BLF::UncompressedFile::nextLogContainer
virtual void nextLogContainer()
Definition UncompressedFile.cpp:224
Vector::BLF::UncompressedFile::defaultLogContainerSize
virtual uint32_t defaultLogContainerSize() const
Definition UncompressedFile.cpp:290
Vector::BLF::UncompressedFile::setBufferSize
virtual void setBufferSize(std::streamsize bufferSize)
Definition UncompressedFile.cpp:261
Vector::BLF::UncompressedFile::dropOldData
virtual void dropOldData()
Definition UncompressedFile.cpp:269
Vector::BLF::UncompressedFile::tellgChanged
std::condition_variable tellgChanged
Definition UncompressedFile.h:109
Vector::BLF::UncompressedFile::abort
virtual void abort()
Definition UncompressedFile.cpp:184
Vector::BLF::UncompressedFile::fileSize
virtual std::streamsize fileSize() const
Definition UncompressedFile.cpp:242
Vector::BLF::UncompressedFile::tellg
std::streampos tellg() override
Definition UncompressedFile.cpp:82