18#define OT_ADD_HANDLER(___functionName, ___className, ___actionName, ___messageTypeFlags) ot::ActionHandleConnector<___className> ActionHandleConnector##___functionName##=ot::ActionHandleConnector<___className>(___actionName, ___messageTypeFlags, this, &___className::___functionName)
26#define OT_HANDLER(___functionName, ___className, ___actionName, ___messageTypeFlags) std::string ___functionName(ot::JsonDocument& _document); OT_ADD_HANDLER(___functionName, ___className, ___actionName, ___messageTypeFlags);
29#define OT_ACTIONLIST(...) std::list<std::string>({__VA_ARGS__})
35 template <
class T>
class __declspec(dllexport) ActionHandleConnector :
public ActionHandleConnectorBase {
37 typedef std::string(T::* ConnectorMessageRef)(JsonDocument&);
48 ConnectorMessageRef getDispatchReference(
void) {
return m_func; }
50 virtual std::string forwardDispatch(JsonDocument& _doc)
override;
54 ConnectorMessageRef m_func;
59ot::ActionHandleConnector<T>::ActionHandleConnector(
void)
64ot::ActionHandleConnector<T>::ActionHandleConnector(
const std::string& _actionName,
ot::MessageType _messageFlags,
ActionHandler* _obj, ConnectorMessageRef _func)
65 : ActionHandleConnectorBase(_actionName, _messageFlags), m_obj(_obj), m_func(_func)
69ot::ActionHandleConnector<T>::ActionHandleConnector(
const std::initializer_list<const char*>& _actionNames,
ot::MessageType _messageFlags,
ActionHandler* _obj, ConnectorMessageRef _func)
70 : ActionHandleConnectorBase(
std::list<
std::
string>(_actionNames), _messageFlags), m_obj(_obj), m_func(_func) {
74ot::ActionHandleConnector<T>::ActionHandleConnector(
const std::list<std::string>& _actionNames,
ot::MessageType _messageFlags,
ActionHandler* _obj, ConnectorMessageRef _func)
75 : ActionHandleConnectorBase(_actionNames, _messageFlags), m_obj(_obj), m_func(_func)
80 : ActionHandleConnectorBase(_other), m_obj(_other.m_obj), m_func(_other.m_func)
85 ActionHandleConnectorBase::operator=(_other);
87 m_func = _other.m_func;
91std::string ot::ActionHandleConnector<T>::forwardDispatch(JsonDocument& _doc) {
93 return std::invoke(m_func,
dynamic_cast<T*
>(m_obj), _doc);
96 OTAssert(0,
"Handler function not set");
std::string string
Definition DocumentAccess.h:13
#define OTAssert(___expression, ___message)
Adds the ability to provide a custom text to the cassert macro (assertion only in debug mode)
Definition OTAssert.h:16
The ActionHandleConnector is used as a connector between the [ActionDispatcher] and a function in a [...
Definition ActionHandler.h:10
MessageType
The message types describes how a message should be delivered.
Definition CommunicationTypes.h:10
@ ALL_MESSAGE_TYPES
Definition CommunicationTypes.h:15