contur2
Loading...
Searching...
No Matches
contur::DeviceManager Class Reference

Registry and dispatcher for I/O devices. More...

#include <device_manager.h>

Public Member Functions

 DeviceManager ()
 ~DeviceManager ()
 DeviceManager (const DeviceManager &)=delete
DeviceManageroperator= (const DeviceManager &)=delete
 DeviceManager (DeviceManager &&) noexcept
DeviceManageroperator= (DeviceManager &&) noexcept
Result< void > registerDevice (std::unique_ptr< IDevice > device)
 Registers a device. Takes ownership.
Result< void > unregisterDevice (DeviceId id)
 Removes and destroys a device by ID.
std::optional< std::reference_wrapper< IDevice > > getDevice (DeviceId id) noexcept
 Returns a non-owning reference to the device with the given ID, if present.
std::optional< std::reference_wrapper< const IDevice > > getDevice (DeviceId id) const noexcept
 Returns a const non-owning reference to the device with the given ID, if present.
Result< void > write (DeviceId id, RegisterValue value)
 Writes a value to the device with the given ID.
Result< RegisterValueread (DeviceId id)
 Reads a value from the device with the given ID.
std::size_t deviceCount () const noexcept
 Returns the number of registered devices.
bool hasDevice (DeviceId id) const noexcept
 Returns true if a device with the given ID is registered.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Registry and dispatcher for I/O devices.

The DeviceManager owns all registered devices (via unique_ptr) and provides lookup by DeviceId for read/write dispatch.

Definition at line 26 of file device_manager.h.

Constructor & Destructor Documentation

◆ DeviceManager() [1/3]

contur::DeviceManager::DeviceManager ( )

◆ ~DeviceManager()

contur::DeviceManager::~DeviceManager ( )

◆ DeviceManager() [2/3]

contur::DeviceManager::DeviceManager ( const DeviceManager & )
delete

◆ DeviceManager() [3/3]

contur::DeviceManager::DeviceManager ( DeviceManager && )
noexcept

Member Function Documentation

◆ deviceCount()

std::size_t contur::DeviceManager::deviceCount ( ) const
nodiscardnoexcept

Returns the number of registered devices.

◆ getDevice() [1/2]

std::optional< std::reference_wrapper< const IDevice > > contur::DeviceManager::getDevice ( DeviceId id) const
nodiscardnoexcept

Returns a const non-owning reference to the device with the given ID, if present.

◆ getDevice() [2/2]

std::optional< std::reference_wrapper< IDevice > > contur::DeviceManager::getDevice ( DeviceId id)
nodiscardnoexcept

Returns a non-owning reference to the device with the given ID, if present.

◆ hasDevice()

bool contur::DeviceManager::hasDevice ( DeviceId id) const
nodiscardnoexcept

Returns true if a device with the given ID is registered.

◆ operator=() [1/2]

DeviceManager & contur::DeviceManager::operator= ( const DeviceManager & )
delete

◆ operator=() [2/2]

DeviceManager & contur::DeviceManager::operator= ( DeviceManager && )
noexcept

◆ read()

Result< RegisterValue > contur::DeviceManager::read ( DeviceId id)
nodiscard

Reads a value from the device with the given ID.

Returns
The read value, or NotFound/DeviceError on failure.

◆ registerDevice()

Result< void > contur::DeviceManager::registerDevice ( std::unique_ptr< IDevice > device)
nodiscard

Registers a device. Takes ownership.

Parameters
deviceThe device to register.
Returns
Success, or AlreadyExists if a device with the same ID is already registered.

◆ unregisterDevice()

Result< void > contur::DeviceManager::unregisterDevice ( DeviceId id)
nodiscard

Removes and destroys a device by ID.

Returns
Success, or NotFound if no device with the given ID exists.

◆ write()

Result< void > contur::DeviceManager::write ( DeviceId id,
RegisterValue value )
nodiscard

Writes a value to the device with the given ID.

Returns
Success, or NotFound/DeviceError on failure.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::DeviceManager::impl_
private

Definition at line 69 of file device_manager.h.


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