#pragma once #include #include #include #include #include #include "ServerState.hh" class Shell { public: Shell(std::shared_ptr base); virtual ~Shell() = default; Shell(const Shell&) = delete; Shell(Shell&&) = delete; Shell& operator=(const Shell&) = delete; Shell& operator=(Shell&&) = delete; static const std::string PROMPT; protected: std::shared_ptr base; std::unique_ptr read_event; std::unique_ptr prompt_event; Poll poll; class exit_shell : public std::runtime_error { public: exit_shell(); ~exit_shell() = default; }; static void dispatch_print_prompt(evutil_socket_t fd, short events, void* ctx); static void dispatch_read_stdin(evutil_socket_t fd, short events, void* ctx); virtual void print_prompt(); void read_stdin(); virtual void execute_command(const std::string& command) = 0; };