#pragma once #include #include #include 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(Process&) const override; virtual bool can_write(Process&) const override { return true; } virtual ssize_t read(Process&, byte*, ssize_t) override; virtual ssize_t write(Process&, 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& logbuffer() const { return m_logbuffer; } private: ConsoleImplementation* m_implementation { nullptr }; CircularQueue m_logbuffer; };