contur2
Loading...
Searching...
No Matches
i_device.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <string_view>
11
12#include "contur/core/error.h"
13#include "contur/core/types.h"
14
15namespace contur {
16
21 class IDevice
22 {
23 public:
24 virtual ~IDevice() = default;
25
27 [[nodiscard]] virtual DeviceId id() const noexcept = 0;
28
30 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
31
34 [[nodiscard]] virtual Result<RegisterValue> read() = 0;
35
39 [[nodiscard]] virtual Result<void> write(RegisterValue value) = 0;
40
42 [[nodiscard]] virtual bool isReady() const noexcept = 0;
43
44 protected:
45 IDevice() = default;
46 IDevice(const IDevice &) = default;
47 IDevice &operator=(const IDevice &) = default;
48 IDevice(IDevice &&) = default;
49 IDevice &operator=(IDevice &&) = default;
50 };
51
52} // namespace contur
IDevice()=default
virtual ~IDevice()=default
virtual std::string_view name() const noexcept=0
Returns the human-readable device name.
virtual DeviceId id() const noexcept=0
Returns the unique device identifier.
virtual bool isReady() const noexcept=0
Returns true if the device is ready for I/O operations.
virtual Result< void > write(RegisterValue value)=0
Writes a value to the device.
virtual Result< RegisterValue > read()=0
Reads a value from the device.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Error codes and Result<T> type for fallible operations.
Definition block.h:15
std::int32_t RegisterValue
Value stored in a CPU register.
Definition types.h:21
std::uint16_t DeviceId
Unique identifier for an I/O device.
Definition types.h:24
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...