contur2
Loading...
Searching...
No Matches
console_device.h
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <memory>
10
11#include "contur/io/i_device.h"
12
13namespace contur {
14
19 class ConsoleDevice final : public IDevice
20 {
21 public:
23 static constexpr DeviceId CONSOLE_DEVICE_ID = 1;
24
26 ~ConsoleDevice() override;
27
28 // Non-copyable, movable
29 ConsoleDevice(const ConsoleDevice &) = delete;
32 ConsoleDevice &operator=(ConsoleDevice &&) noexcept;
33
34 [[nodiscard]] DeviceId id() const noexcept override;
35 [[nodiscard]] std::string_view name() const noexcept override;
36 [[nodiscard]] Result<RegisterValue> read() override;
37 [[nodiscard]] Result<void> write(RegisterValue value) override;
38 [[nodiscard]] bool isReady() const noexcept override;
39
40 private:
41 struct Impl;
42 std::unique_ptr<Impl> impl_;
43 };
44
45} // namespace contur
std::string_view name() const noexcept override
Returns the human-readable device name.
~ConsoleDevice() override
bool isReady() const noexcept override
Returns true if the device is ready for I/O operations.
Result< RegisterValue > read() override
Reads a value from the device.
ConsoleDevice(ConsoleDevice &&) noexcept
std::unique_ptr< Impl > impl_
ConsoleDevice & operator=(const ConsoleDevice &)=delete
ConsoleDevice(const ConsoleDevice &)=delete
static constexpr DeviceId CONSOLE_DEVICE_ID
Default console device ID.
Result< void > write(RegisterValue value) override
Writes a value to the device.
IDevice()=default
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
IDevice — abstract interface for I/O devices.
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