summaryrefslogtreecommitdiff
path: root/Kernel/Console.h
blob: ff225bf42b8a51f480e0de7b5b4b94298418748f (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
#pragma once

#include <AK/Compiler.h>
#include <AK/Vector.h>
#include <VirtualFileSystem/CharacterDevice.h>

class ConsoleImplementation {
public:
    virtual ~ConsoleImplementation();
    virtual void onConsoleReceive(byte) = 0;
};

class Console final : public CharacterDevice {
    AK_MAKE_ETERNAL
public:
    static Console& the() PURE;

    Console();
    virtual ~Console() override;

    virtual bool hasDataAvailableForRead() const override;
    virtual ssize_t read(byte* buffer, size_t size) override;
    virtual ssize_t write(const byte* data, size_t size) override;

    void setImplementation(ConsoleImplementation* implementation) { m_implementation = implementation; }

    void putChar(char);

private:
    ConsoleImplementation* m_implementation { nullptr };
};