StormByte-Buffer 2.0.0
C++26 buffer module of the StormByte suite
 
Loading...
Searching...
No Matches
buffered_location_writer.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Buffer.
5 *
6 * StormByte-Buffer original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Buffer source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte-Logger tree and
23 * the rest of the StormByte suite it vendors), which remains under its own
24 * license.
25 *
26 * Neither license grants any patent rights. Any patent licenses required
27 * to use this software or third-party components must be obtained separately
28 * from the patent holders.
29 *
30 * StormByte-Buffer is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public License
36 * version 3 along with StormByte-Buffer. If not, see
37 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
38 *
39 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
40 */
41
42#pragma once
43
49
50#include <chrono>
51#include <memory>
52#include <utility>
53
58namespace StormByte {
63 namespace Buffer {
68 namespace Backend {
73 namespace IO {
79 }
80 }
81
86 namespace IO {
120 public:
126 public:
127 using BufferedWriter::Parameters::Parameters;
128 };
129
134
140
144 virtual ~BufferedLocationWriter() noexcept override;
145
151
157 BufferedLocationWriter& operator=(BufferedLocationWriter&& other) noexcept;
158
166 StormByte::Shared<StormByte::System::Device> Device() const;
167
172 bool IsSeekable() const noexcept;
173
178 bool IsSized() const noexcept;
179
184 StormByte::ByteSize Size() const noexcept final;
185
186 protected:
195 STORMBYTE_FORCE_INLINE BufferedLocationWriter(StormByte::String::String path,
196 enum Location location, Parameters parameters = {}):
197 BufferedLocationWriter(std::move(path), location,
198 parameters.WriteChunk().value_or(StormByte::ByteSize{0}),
199 parameters.BackPressure().value_or(0),
200 parameters.MaxWait().value_or(std::chrono::milliseconds{0}),
201 parameters.MaxMemory().value_or(StormByte::ByteSize{0}),
202 !parameters.WriteChunk().has_value()
203 && !parameters.BackPressure().has_value()
204 && !parameters.MaxMemory().has_value()) {}
205
219 StormByte::ByteSize write_chunk, std::size_t back_pressure,
220 std::chrono::milliseconds max_wait, StormByte::ByteSize max_memory, bool probe);
221
230
242 virtual bool OriginDeviceUsable(const StormByte::Shared<StormByte::System::Device>& device) const noexcept;
243
248 virtual StormByte::ByteSize OriginSize() const noexcept = 0;
249
255 virtual Result OriginSeek(StormByte::ByteSize absolute) = 0;
256
264 void Setup() final;
265
266 private:
267 std::unique_ptr<StormByte::Buffer::Backend::IO::BufferedLocationWriter> m_io;
268 };
269 }
270 }
271}
Private state of StormByte::Buffer::IO::BufferedLocationWriter.
Writer ring cap in WriteChunk units.
Definition parameters.hxx:177
Location-writer knobs.
Definition buffered_location_writer.hxx:125
File-like BufferedWriter.
Definition buffered_location_writer.hxx:119
BufferedLocationWriter(const BufferedLocationWriter &)=delete
Copy constructor is deleted.
BufferedLocationWriter(BufferedLocationWriter &&other) noexcept
Move constructor.
virtual bool OriginDeviceUsable(const StormByte::Shared< StormByte::System::Device > &device) const noexcept
Whether Setup may read windows from device.
virtual StormByte::ByteSize OriginSize() const noexcept=0
Length the leaf can answer.
virtual StormByte::Shared< StormByte::System::Device > OriginDevice() const =0
Leaf measurement.
virtual ~BufferedLocationWriter() noexcept override
Destructor.
BufferedLocationWriter(StormByte::String::String path, enum Location location, StormByte::ByteSize write_chunk, std::size_t back_pressure, std::chrono::milliseconds max_wait, StormByte::ByteSize max_memory, bool probe)
Forward the locator and the sink knobs.
Writer knobs.
Definition buffered_writer.hxx:244
Coordinated binary write sink with optional chunked write-behind and a delayed-seek page map.
Definition buffered_writer.hxx:231
Cache / dirty-page budget knob.
Definition parameters.hxx:102
Origin wait cap.
Definition parameters.hxx:127
Origin push unit.
Definition parameters.hxx:152
Location
Where the bytes of a file-like source or sink live.
Definition typedefs.hxx:140
Root namespace of the StormByte C++ suite.
STL namespace.
Per-call status plus how many bytes this call transferred.
Definition typedefs.hxx:168
#define STORMBYTE_BUFFER_PUBLIC
Definition visibility.h:54