39 #ifndef LOCAL_SERVER_API__
40 #define LOCAL_SERVER_API__
42 #include <wx/cmdline.h>
44 #include "observable_evtvar.h"
46 using LocalApiResult = std::pair<bool, std::string>;
48 enum class CmdlineAction { Raise, Quit, Open, GetRestEndpoint, Fail, Skip };
55 const char* str() {
return reason.c_str(); }
82 get_rest_api_endpoint_cb = cb;
85 std::function<std::string()> get_rest_api_endpoint_cb;
89 : get_rest_api_endpoint_cb([](){
return "0.0.0.0/1024"; }) {}
96 static std::unique_ptr<LocalClientApi> GetClient();
102 virtual LocalApiResult HandleCmdline(
const wxCmdLineParser& parser);
103 virtual LocalApiResult HandleCmdline(CmdlineAction action,
const std::string& arg);
105 virtual LocalApiResult SendRaise() = 0;
106 virtual LocalApiResult SendOpen(
const char* path) = 0;
107 virtual LocalApiResult SendQuit() = 0;
108 virtual LocalApiResult GetRestEndpoint() = 0;
111 CmdlineAction ParseArgs(
const wxCmdLineParser& parser, std::string& arg);
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Base interface for local clients.
Base interface for local server command handling.
std::function< bool(const std::string &)> open_file_cb
Callback invoked on open command with a file path argument.
static void ReleaseInstance()
Release Instance.
virtual void SetGetRestApiEndpointCb(std::function< std::string()> cb)
Set callback returning the rest server root endpoint.
EventVar on_raise
Notified on the Raise command.
EventVar on_quit
Notified on the Quit command.
static LocalServerApi & GetInstance()