2018-10-21 21:59:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2018-10-26 22:32:35 +02:00
|
|
|
#include <AK/Compiler.h>
|
2018-10-27 23:42:20 +02:00
|
|
|
#include <AK/Vector.h>
|
2018-10-21 21:59:43 +02:00
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
|
|
|
|
|
2018-10-30 13:59:29 +01:00
|
|
|
class ConsoleImplementation {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~ConsoleImplementation();
|
|
|
|
|
virtual void onConsoleReceive(byte) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-21 21:59:43 +02:00
|
|
|
class Console final : public CharacterDevice {
|
|
|
|
|
public:
|
2018-10-26 18:43:25 +02:00
|
|
|
static Console& the() PURE;
|
2018-10-21 21:59:43 +02:00
|
|
|
|
|
|
|
|
Console();
|
|
|
|
|
virtual ~Console() override;
|
|
|
|
|
|
2018-10-25 13:07:59 +02:00
|
|
|
virtual bool hasDataAvailableForRead() const override;
|
2018-10-21 21:59:43 +02:00
|
|
|
virtual ssize_t read(byte* buffer, size_t size) override;
|
|
|
|
|
virtual ssize_t write(const byte* data, size_t size) override;
|
|
|
|
|
|
2018-10-30 13:59:29 +01:00
|
|
|
void setImplementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
|
|
|
|
|
|
2018-10-21 22:11:46 +02:00
|
|
|
void putChar(char);
|
|
|
|
|
|
2018-10-23 15:19:02 +02:00
|
|
|
private:
|
2018-10-30 13:59:29 +01:00
|
|
|
ConsoleImplementation* m_implementation { nullptr };
|
2018-10-21 21:59:43 +02:00
|
|
|
};
|
|
|
|
|
|