blob: 59fe006c4e06b6842f66111fab3aed6664d1269f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
#include <AK/CircularQueue.h>
#include <AK/Vector.h>
#include <Kernel/Devices/CharacterDevice.h>
class ConsoleImplementation {
public:
virtual ~ConsoleImplementation();
virtual void on_sysconsole_receive(byte) = 0;
};
class Console final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
static Console& the();
Console();
virtual ~Console() override;
// ^CharacterDevice
virtual bool can_read(FileDescriptor&) const override;
virtual bool can_write(FileDescriptor&) const override { return true; }
virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override;
virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override;
virtual const char* class_name() const override { return "Console"; }
void set_implementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
void put_char(char);
const CircularQueue<char, 16384>& logbuffer() const { return m_logbuffer; }
private:
ConsoleImplementation* m_implementation { nullptr };
CircularQueue<char, 16384> m_logbuffer;
};
|