![]() |
Contur 2
Educational OS kernel simulator
|
Registry and dispatcher for I/O devices. More...
#include <device_manager.h>
Public Member Functions | |
| DeviceManager () | |
| Constructs an empty device registry. | |
| ~DeviceManager () | |
| Destroys registry and owned devices. | |
| DeviceManager (const DeviceManager &)=delete | |
| DeviceManager & | operator= (const DeviceManager &)=delete |
| DeviceManager (DeviceManager &&) noexcept | |
| Move-constructs registry state. | |
| DeviceManager & | operator= (DeviceManager &&) noexcept |
| Move-assigns registry state. | |
| 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< RegisterValue > | read (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_ |
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.
| contur::DeviceManager::DeviceManager | ( | ) |
Constructs an empty device registry.
Referenced by DeviceManager(), DeviceManager(), operator=(), and operator=().
| contur::DeviceManager::~DeviceManager | ( | ) |
Destroys registry and owned devices.
|
delete |
References DeviceManager().
|
noexcept |
Move-constructs registry state.
References DeviceManager().
|
nodiscardnoexcept |
|
nodiscardnoexcept |
Returns a const non-owning reference to the device with the given ID, if present.
References getDevice().
|
nodiscardnoexcept |
Returns a non-owning reference to the device with the given ID, if present.
References getDevice().
Referenced by getDevice(), and getDevice().
|
nodiscardnoexcept |
Returns true if a device with the given ID is registered.
References hasDevice().
Referenced by hasDevice().
|
delete |
References DeviceManager().
|
noexcept |
Move-assigns registry state.
References DeviceManager().
|
nodiscard |
Registers a device. Takes ownership.
| device | The device to register. |
References registerDevice().
Referenced by registerDevice().
Removes and destroys a device by ID.
References unregisterDevice().
Referenced by unregisterDevice().
|
nodiscard |
|
private |
Definition at line 75 of file device_manager.h.