/* * Copyright (c) 2020, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Chess::UCI { class Endpoint : public Core::Object { C_OBJECT(Endpoint) public: virtual ~Endpoint() override { } Endpoint() { } Endpoint(NonnullRefPtr in, NonnullRefPtr out); virtual void handle_uci() { } virtual void handle_debug(const DebugCommand&) { } virtual void handle_isready() { } virtual void handle_setoption(const SetOptionCommand&) { } virtual void handle_position(const PositionCommand&) { } virtual void handle_go(const GoCommand&) { } virtual void handle_stop() { } virtual void handle_id(const IdCommand&) { } virtual void handle_uciok() { } virtual void handle_readyok() { } virtual void handle_bestmove(const BestMoveCommand&) { } virtual void handle_info(const InfoCommand&) { } void send_command(const Command&); virtual void event(Core::Event&); Core::IODevice& in() { return *m_in; } Core::IODevice& out() { return *m_out; } void set_in(RefPtr in) { m_in = in; set_in_notifier(); } void set_out(RefPtr out) { m_out = out; } private: void set_in_notifier(); NonnullOwnPtr read_command(); RefPtr m_in; RefPtr m_out; RefPtr m_in_notifier; }; }