Final BufferedLocationReader over a filesystem file. More...
#include <StormByte/buffer/io/buffered_file_reader.hxx>


Classes | |
| class | Parameters |
| File-reader knobs. More... | |
Public Member Functions | |
Lifecycle | |
| STORMBYTE_FORCE_INLINE | BufferedFileReader (StormByte::String::String path, Parameters parameters={}) |
| Store the path and optional knobs. | |
| BufferedFileReader (const BufferedFileReader &)=delete | |
| Copy constructor is deleted. | |
| BufferedFileReader (BufferedFileReader &&other) noexcept | |
| Move constructor. | |
| ~BufferedFileReader () noexcept override | |
| Destructor. | |
| BufferedFileReader & | operator= (const BufferedFileReader &)=delete |
| Copy assignment is deleted. | |
| BufferedFileReader & | operator= (BufferedFileReader &&other) noexcept |
| Move assignment. | |
Public Member Functions inherited from StormByte::Buffer::IO::BufferedLocationReader | |
| BufferedLocationReader (const BufferedLocationReader &)=delete | |
| Copy constructor is deleted. | |
| BufferedLocationReader (BufferedLocationReader &&other) noexcept | |
| Move constructor. | |
| virtual | ~BufferedLocationReader () noexcept override |
| Destructor. | |
| BufferedLocationReader & | operator= (const BufferedLocationReader &)=delete |
| Copy assignment is deleted. | |
| BufferedLocationReader & | operator= (BufferedLocationReader &&other) noexcept |
| Move assignment. | |
| StormByte::Shared< StormByte::System::Device > | Device () const |
| Measurement of this location. | |
Public Member Functions inherited from StormByte::Buffer::IO::BufferedReader | |
| const StormByte::String::String & | Path () const noexcept |
| Locator stored at construction. | |
| enum Location | Location () const noexcept |
| Where Path points. | |
| virtual | operator bool () const noexcept final |
| Whether the source is prepared to read. | |
| virtual enum State | State () const noexcept final |
| Session state. | |
| BufferedReader (const BufferedReader &)=delete | |
| Copy constructor is deleted. | |
| BufferedReader (BufferedReader &&other) noexcept | |
| Move constructor. | |
| virtual | ~BufferedReader () noexcept |
| Virtual destructor. | |
| BufferedReader & | operator= (const BufferedReader &)=delete |
| Copy assignment is deleted. | |
| BufferedReader & | operator= (BufferedReader &&other) noexcept |
| Move assignment. | |
| virtual bool | Open () final |
| Arm the origin. | |
| virtual Result | Close () final |
| Stop prefetch, drop caches, close the origin. | |
| virtual bool | Rewind () final |
| Re-arm an open source: Close then Open. | |
| virtual bool | IsOpen () const noexcept final |
| Whether Open succeeded and Close has not. | |
| virtual bool | IsReadable () const noexcept final |
| Whether reads may be attempted. | |
| virtual bool | EoF () const noexcept final |
| Whether no further bytes can be produced. | |
| virtual StormByte::ByteSize | Available () const noexcept final |
| Cached bytes readable at Tell without touching the origin. | |
| virtual Result | Read (StormByte::ByteSize n, FIFO &dest) const final |
Read n bytes into dest, consuming cache / origin. | |
| virtual Result | Read (std::span< std::byte > dest) const final |
Read into dest, consuming cache / origin. | |
| virtual Result | Peek (StormByte::ByteSize n, FIFO &dest) const final |
Copy n bytes into dest without consuming cache. | |
| virtual Result | Peek (std::span< std::byte > dest) const final |
Copy into dest without consuming cache. | |
| virtual Result | Seek (std::ptrdiff_t offset, Position mode) const final |
| Move the logical read cursor. | |
| virtual StormByte::ByteSize | Tell () const noexcept final |
| Logical read offset in the stream. | |
| virtual bool | IsSeekable () const noexcept final |
| Whether this instance can reposition the origin. | |
| virtual bool | IsSized () const noexcept final |
| Whether the origin length is known. | |
| virtual std::optional< StormByte::ByteSize > | Size () const noexcept final |
| Origin length in bytes when known. | |
| const StormByte::Shared< StormByte::Buffer::ReadTelemetry > | Telemetry () const noexcept |
| Shared read counters. | |
| virtual StormByte::ByteSize | ReadAhead () const noexcept |
| Configured prefetch length in bytes. | |
| virtual void | ReadAhead (StormByte::ByteSize bytes) |
| Set prefetch length. | |
| virtual StormByte::ByteSize | MaxMemory () const noexcept |
| Configured cache memory cap in bytes. | |
| virtual void | MaxMemory (StormByte::ByteSize bytes) |
| Set cache memory cap. | |
| virtual std::chrono::milliseconds | MaxWait () const noexcept |
| Configured read wait limit. | |
| virtual void | MaxWait (std::chrono::milliseconds wait) |
| Set read wait limit. | |
Protected Member Functions | |
| StormByte::Shared< StormByte::System::Device > | OriginDevice () const override |
| Device for the location probe. | |
| Result | OriginOpen () override |
| Open the file as a binary input and cache its size. | |
| Result | OriginClose () override |
| Close the file stream. | |
| Result | OriginPull (StormByte::ByteSize n, FIFO &dest) override |
Read up to n bytes from the file into dest. | |
| Result | OriginSeek (std::ptrdiff_t offset, Position mode) override |
| Seek the file stream. | |
| std::optional< StormByte::ByteSize > | OriginSize () const noexcept override |
| Cached file size. | |
Protected Member Functions inherited from StormByte::Buffer::IO::BufferedLocationReader | |
| STORMBYTE_FORCE_INLINE | BufferedLocationReader (StormByte::String::String path, enum Location location, Parameters parameters={}) |
| Store the locator and resolve knobs in the caller. | |
| BufferedLocationReader (StormByte::String::String path, enum Location location, StormByte::ByteSize read_ahead, StormByte::ByteSize max_memory, std::chrono::milliseconds max_wait, bool probe) | |
| Store the locator and forward the cache knobs. | |
| virtual bool | OriginDeviceUsable (const StormByte::Shared< StormByte::System::Device > &device) const noexcept |
Whether Setup may read windows from device. | |
| bool | OriginCanSeek () const noexcept final |
| A location can seek. | |
| bool | OriginHasSize () const noexcept final |
| A location has a length. | |
| void | Setup () final |
| Apply the device read window when the constructor asked for a probe. | |
Protected Member Functions inherited from StormByte::Buffer::IO::BufferedReader | |
| STORMBYTE_FORCE_INLINE | BufferedReader (StormByte::String::String path, enum Location location, Parameters parameters={}) |
| Construct an unopened coordinator (State::Unavailable). | |
| BufferedReader (StormByte::String::String path, enum Location location, StormByte::ByteSize read_ahead, StormByte::ByteSize max_memory, std::chrono::milliseconds max_wait) | |
| Construct an unopened coordinator (State::Unavailable). | |
| void | SetState (enum State state) noexcept |
| Publish session state from a leaf hook. | |
| virtual StormByte::Shared< StormByte::Buffer::ReadTelemetry > | CreateTelemetry () const |
| Allocate the telemetry object this instance will keep. | |
Final BufferedLocationReader over a filesystem file.
Binary ifstream only. Hooks call SetState. Does not open in the constructor.
The device does not change after construction: ReadAhead is chosen once by BufferedLocationReader::Setup when the caller omitted that knob. Cache size (MaxMemory) stays dynamic.
BufferedFileReader(path) and BufferedFileReader(path, {}) ask the location layer to probe Device at Setup. Initial MaxMemory is 1 MiB. BufferedFileReader(path, { ReadAhead(n), MaxMemory(m) }) stores those values and does not probe. ReadAhead 0 disables prefetch. MaxMemory 0 stores no cache.Parameters is resolved in the caller (STORMBYTE_FORCE_INLINE). The DLL sees only numbers and the probe flag.
This leaf only opens, reads, seeks and reports the file length. OriginDevice builds a StormByte::System::Device from Location.
|
inlineexplicit |
|
delete |
Copy constructor is deleted.
|
noexcept |
Move constructor.
| other | Instance to take from. |
|
overridenoexcept |
Destructor.
Calls Close while the leaf vtable is live.
|
noexcept |
Move assignment.
| other | Instance to take from. |
|
delete |
Copy assignment is deleted.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Device for the location probe.
The base type is used as is, so usability is the real path probe.
Implements StormByte::Buffer::IO::BufferedLocationReader.
|
overrideprotectedvirtual |
Open the file as a binary input and cache its size.
Implements StormByte::Buffer::IO::BufferedReader.
|
overrideprotectedvirtual |
Read up to n bytes from the file into dest.
| n | Maximum bytes. |
| dest | Base-owned FIFO. |
Implements StormByte::Buffer::IO::BufferedReader.
|
overrideprotectedvirtual |
Seek the file stream.
| offset | Byte offset. |
| mode | Absolute from start or relative to the file cursor. |
Implements StormByte::Buffer::IO::BufferedReader.
|
overrideprotectedvirtualnoexcept |
Cached file size.
Implements StormByte::Buffer::IO::BufferedReader.