Contur 2
Educational OS kernel simulator
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
27
29 ~ConsoleDevice() override;
30
31 // Non-copyable, movable
32 ConsoleDevice(const ConsoleDevice &) = delete;
36
38 ConsoleDevice &operator=(ConsoleDevice &&) noexcept;
39
41 [[nodiscard]] DeviceId id() const noexcept override;
42
44 [[nodiscard]] std::string_view name() const noexcept override;
45
47 [[nodiscard]] Result<RegisterValue> read() override;
48
50 [[nodiscard]] Result<void> write(RegisterValue value) override;
51
53 [[nodiscard]] bool isReady() const noexcept override;
54
55 private:
56 struct Impl;
57 std::unique_ptr<Impl> impl_;
58 };
59
60} // namespace contur
std::string_view name() const noexcept override
Returns the human-readable device name.
~ConsoleDevice() override
Destroys console device.
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()
Constructs console device in ready state.
ConsoleDevice(ConsoleDevice &&) noexcept
Move-constructs console device state.
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