4 #ifndef SWIFT_SIM_XSWIFTBUS_COMMAND_H
5 #define SWIFT_SIM_XSWIFTBUS_COMMAND_H
9 #include <XPLMUtilities.h>
23 CCommand(
const char *name,
const char *description, std::function<
void()> handler)
24 : m_handler(handler), m_command(XPLMCreateCommand(name, description))
26 XPLMRegisterCommandHandler(m_command, callback,
false,
static_cast<void *
>(
this));
30 ~CCommand() { XPLMUnregisterCommandHandler(m_command, callback,
false,
static_cast<void *
>(
this)); }
39 static int callback(XPLMCommandRef, XPLMCommandPhase phase,
void *refcon)
41 if (phase == xplm_CommandBegin) { (
static_cast<CCommand *
>(refcon)->m_handler)(); }
45 std::function<void()> m_handler;
46 XPLMCommandRef m_command;
Class-based interface to X-Plane's custom command API.
CCommand & operator=(const CCommand &)=delete
Not copyable.
CCommand(const CCommand &)=delete
Not copyable.
CCommand(const char *name, const char *description, std::function< void()> handler)
Constructor.
Plugin loaded by X-Plane which publishes a DBus service.