RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
24 #ifndef LAUNCHER_PLUGINS_ABSTRACT_COMMUNICATOR_HPP
25 #define LAUNCHER_PLUGINS_ABSTRACT_COMMUNICATOR_HPP
27 #include <Noncopyable.hpp>
32 namespace launcher_plugins {
46 namespace launcher_plugins {
52 typedef std::function<void(
const std::shared_ptr<api::Request>&)> RequestHandler;
59 public std::enable_shared_from_this<AbstractLauncherCommunicator>
138 template <
typename Derived>
142 std::is_base_of<AbstractLauncherCommunicator, Derived>::value,
143 "Derived must inherit from AbstractLauncherCommunicator");
145 return std::static_pointer_cast<Derived>(shared_from_this());
157 virtual void writeResponse(
const std::string& in_responseMessage) = 0;
160 PRIVATE_IMPL(m_baseImpl);
163 typedef std::shared_ptr<AbstractLauncherCommunicator> AbstractLauncherCommunicatorPtr;
void registerRequestHandler(std::unique_ptr< RequestHandler > &&in_requestHandler)
Registers a request handler for all requests.
virtual Error start()
Starts the communicator.
void reportError(const Error &in_error)
Reports an error and stops the communicator.
void onDataReceived(const char *in_data, size_t in_length)
Handles data that is received from the RStudio Launcher.
virtual ~AbstractLauncherCommunicator()=default
Virtual destructor to allow for inheritance.
std::function< void(const Error &)> OnError
Definition: Functionals.hpp:43
AbstractLauncherCommunicator(size_t in_maxMessageSize, const OnError &in_onError)
Constructor.
Class which represents an error.
Definition: Error.hpp:174
void sendResponse(const api::Response &in_response)
Sends the response to the RStudio Launcher.
std::shared_ptr< Derived > shared_from_derived()
Definition: AbstractLauncherCommunicator.hpp:139
Represents the common components of all responses which can be sent the RStudio Launcher.
Definition: Response.hpp:56
virtual void waitForExit()
Blocks until the communicator has successfully stopped.
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
Base class responsible for communicating the the launcher. The type of communication is implementatio...
Definition: AbstractLauncherCommunicator.hpp:58
virtual void stop()
Stops the communicator.