StormByte-System 2.0.0
C++26 process and environment module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::System::Device Class Reference

Query object for the medium behind a filesystem accessor. More...

#include <StormByte/system/device.hxx>

Classes

class  Access
 Bitmask of AccessFlag. More...
 
struct  Throughput
 Nominal sequential rates of the resolved medium. More...
 
struct  Window
 Suggested transfer windows derived from Throughput. More...
 

Public Types

enum class  Error {
  Success = 0 , BrokenSymlink , DeviceNotFound , NotADevice ,
  Permission , ProbeFailed
}
 Device classification and probe enumerators. More...
 
enum class  Kind {
  HDD , SSD , NVMeGen3 , NVMeGen4 ,
  NVMeGen5 , USBHDD , USBStick , Network
}
 Classified storage or network medium. More...
 
enum class  AccessFlag : std::uint8_t { Readable = 0x01 , Writable = 0x02 }
 Transfer permission of this path for this process. More...
 

Public Member Functions

Lifecycle
 Device (const StormByte::String::String &path) noexcept
 Store an owned UTF-8 accessor.
 
 Device (std::string_view path) noexcept
 Store a UTF-8 accessor view.
 
 Device (std::wstring_view path) noexcept
 Store a wide accessor as UTF-8 text.
 
 Device (const std::filesystem::path &path) noexcept
 Store a filesystem path as UTF-8 text.
 
 Device (const Device &)=default
 Copy constructor.
 
 Device (Device &&) noexcept=default
 Move constructor.
 
Device & operator= (const Device &)=default
 Copy assignment.
 
Device & operator= (Device &&) noexcept=default
 Move assignment.
 
virtual ~Device ()=default
 Destructor.
 
Probe
 operator bool () const noexcept
 Whether the current probe succeeded.
 
StormByte::Error::Fault Fault () const noexcept
 Result of the current probe.
 
const StormByte::String::String & Path () const noexcept
 Accessor stored at construction.
 
Classification
enum Kind Kind () const noexcept
 Classified medium.
 
class Access Access () const noexcept
 Transfer permissions for this process on this path.
 
virtual struct Throughput Throughput () const noexcept
 Nominal sequential rates of the medium.
 
virtual struct Window Window () const noexcept
 Suggested read and write windows.
 

Detailed Description

Query object for the medium behind a filesystem accessor.

Stores only the caller path as StormByte::String::String. Fault, Kind, Access, Throughput and Window are computed on each call.

Construction does not throw and does not open a handle. operator bool is true only when the current probe produced a success code. It does not mean readable or writable.

Validity
Kind, Access, Throughput and Window are defined only when the Device converts to true. Path is always the stored accessor.
Path kinds
The accessor may be a regular file, a directory, a missing leaf on an existing volume, or a special device node. Symlinks are followed (stat). A dangling symlink is Error::BrokenSymlink. Special device nodes are never AccessFlag::Writable.
Copy
Copyable, movable and assignable. Only m_path is owned.
Derivation
Throughput and Window are virtual so another module can report its own rates without System talking to sockets.

Member Enumeration Documentation

◆ AccessFlag

enum class StormByte::System::Device::AccessFlag : std::uint8_t
strong

Transfer permission of this path for this process.

Not SMART and not medium feature flags.

Enumerator
Readable 

The process may read this path.

Writable 

The process may write this path.

◆ Error

Device classification and probe enumerators.

Domain tag StormByte.System.Device. Zero is success.

Enumerator
Success 

No error.

BrokenSymlink 

The path is a symlink whose target does not exist.

DeviceNotFound 

No volume or node could be resolved.

NotADevice 

The path exists but is not a classifiable file, directory or device node.

Permission 

The process may not stat or access this path.

ProbeFailed 

Classification I/O failed.

◆ Kind

Classified storage or network medium.

Acronyms stay uppercase. Nominal throughput presets follow Kind.

Enumerator
HDD 

Rotational local disk.

SSD 

Non-rotational local disk that is not NVMe.

NVMeGen3 

NVMe PCIe 3.0.

NVMeGen4 

NVMe PCIe 4.0.

NVMeGen5 

NVMe PCIe 5.0.

USBHDD 

Removable rotational disk.

USBStick 

Removable solid-state key.

Network 

Network filesystem or remote drive.

Constructor & Destructor Documentation

◆ Device() [1/6]

StormByte::System::Device::Device ( const StormByte::String::String &  path)
explicitnoexcept

Store an owned UTF-8 accessor.

Parameters
pathCaller path. Need not exist.

◆ Device() [2/6]

StormByte::System::Device::Device ( std::string_view  path)
explicitnoexcept

Store a UTF-8 accessor view.

Parameters
pathCaller path. Need not exist.

◆ Device() [3/6]

StormByte::System::Device::Device ( std::wstring_view  path)
explicitnoexcept

Store a wide accessor as UTF-8 text.

Parameters
pathCaller path. Need not exist.

◆ Device() [4/6]

StormByte::System::Device::Device ( const std::filesystem::path &  path)
explicitnoexcept

Store a filesystem path as UTF-8 text.

Parameters
pathCaller path. Need not exist.

◆ Device() [5/6]

StormByte::System::Device::Device ( const Device &  )
default

Copy constructor.

◆ Device() [6/6]

StormByte::System::Device::Device ( Device &&  )
defaultnoexcept

Move constructor.

◆ ~Device()

virtual StormByte::System::Device::~Device ( )
virtualdefault

Destructor.

Member Function Documentation

◆ Access()

class Access StormByte::System::Device::Access ( ) const
noexcept

Transfer permissions for this process on this path.

Returns
Access bitmask. Valid only when *this is true.

◆ Fault()

StormByte::Error::Fault StormByte::System::Device::Fault ( ) const
noexcept

Result of the current probe.

Returns
Success or an Error code.

◆ Kind()

enum Kind StormByte::System::Device::Kind ( ) const
noexcept

Classified medium.

Returns
Kind. Valid only when *this is true.

◆ operator bool()

StormByte::System::Device::operator bool ( ) const
explicitnoexcept

Whether the current probe succeeded.

Returns
true if Fault is a success code.

◆ operator=() [1/2]

Device & StormByte::System::Device::operator= ( const Device &  )
default

Copy assignment.

◆ operator=() [2/2]

Device & StormByte::System::Device::operator= ( Device &&  )
defaultnoexcept

Move assignment.

◆ Path()

const StormByte::String::String & StormByte::System::Device::Path ( ) const
noexcept

Accessor stored at construction.

Returns
Owned UTF-8 text. Not a canonical target path.

◆ Throughput()

virtual struct Throughput StormByte::System::Device::Throughput ( ) const
virtualnoexcept

Nominal sequential rates of the medium.

Returns
Throughput. Valid only when *this is true.

A derived Device may replace this with its own rates.

◆ Window()

virtual struct Window StormByte::System::Device::Window ( ) const
virtualnoexcept

Suggested read and write windows.

Returns
Window. Valid only when *this is true.

A derived Device may replace this with its own windows.


The documentation for this class was generated from the following file: