Vector BLF: ObjectQueue.h Source File

Vector BLF

Loading...
Searching...
No Matches
ObjectQueue.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 <mutex>
12#include <queue>
13
14#include <Vector/BLF/ObjectHeaderBase.h>
15#include <Vector/BLF/LogContainer.h>
16
17#include <Vector/BLF/vector_blf_export.h>
18
19namespace Vector {
20namespace BLF {
21
25template <typename T>
26 class VECTOR_BLF_EXPORT ObjectQueue final {
27 public:
28 explicit ObjectQueue() = default;
29 ~ObjectQueue();
30
36 T * read();
37
39 uint32_t tellg() const;
40
48 void write(T * obj);
49
51 uint32_t tellp() const;
52
54 bool good() const;
55
57 bool eof() const;
58
60 void abort();
61
63 void setFileSize(uint32_t fileSize);
64
66 void setBufferSize(uint32_t bufferSize);
67
69 std::condition_variable tellgChanged;
70
72 std::condition_variable tellpChanged;
73
74 private:
76 bool m_abort {};
77
79 std::queue<T *> m_queue {};
80
82 uint32_t m_tellg {};
83
85 uint32_t m_tellp {};
86
88 uint32_t m_bufferSize {std::numeric_limits<uint32_t>::max()};
89
91 uint32_t m_fileSize {std::numeric_limits<uint32_t>::max()};
92
94 std::ios_base::iostate m_rdstate {std::ios_base::goodbit};
95
97 mutable std::mutex m_mutex {};
98};
99
100/* explicit template instantiation */
101extern template class ObjectQueue<ObjectHeaderBase>;
102
103}
104}
Vector::BLF::ObjectQueue
Definition: ObjectQueue.h:26
Vector::BLF::ObjectQueue::tellgChanged
std::condition_variable tellgChanged
Definition: ObjectQueue.h:69
Vector::BLF::ObjectQueue::tellpChanged
std::condition_variable tellpChanged
Definition: ObjectQueue.h:72