39#ifndef LOCAL_SERVER_API__
40#define LOCAL_SERVER_API__
42#include <wx/cmdline.h>
46using LocalApiResult = std::pair<bool, std::string>;
48enum class CmdlineAction { Raise, Quit, Open, GetRestEndpoint, Fail, Skip };
54 const char* str() {
return reason.c_str(); }
84 get_rest_api_endpoint_cb = cb;
87 std::function<std::string()> get_rest_api_endpoint_cb;
91 : get_rest_api_endpoint_cb([]() {
return "0.0.0.0/1024"; }) {}
102 static std::unique_ptr<LocalClientApi> GetClient();
107 virtual LocalApiResult HandleCmdline(
const wxCmdLineParser& parser);
108 virtual LocalApiResult HandleCmdline(CmdlineAction action,
109 const std::string& arg);
111 virtual LocalApiResult SendRaise() = 0;
112 virtual LocalApiResult SendOpen(
const char* path) = 0;
113 virtual LocalApiResult SendQuit() = 0;
114 virtual LocalApiResult GetRestEndpoint() = 0;
117 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()
~LocalServerApi()=default
Destroy the Local Server Api object.
A common variable shared between producer and consumer which supports Listen() and Notify().