OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ActionDispatcher.h
Go to the documentation of this file.
1
5// ###########################################################################################################################################################################################################################################################################################################################
6
7#pragma once
8
9// OpenTwin header
10#include "OTCore/JSON.h"
14
15// std header
16#include <string>
17#include <map>
18#include <list>
19#include <mutex>
20
21#pragma warning(disable : 4251)
22
23namespace ot {
24
25 class ActionHandleConnectorBase;
26
31 public:
33 static ActionDispatcher& instance(void);
34
40 void add(ActionHandleConnectorBase* _handler, bool _overwrite = false);
41 void remove(ActionHandleConnectorBase* _handler);
42
46 char* dispatchWrapper(const char* _json, const char* _senderUrl, ot::MessageType _messageType);
47
49 std::string dispatch(const std::string& _json, ot::MessageType _messageType);
50
52 std::string dispatch(JsonDocument& _document, MessageType _messageType);
53
59 std::string dispatch(const std::string& _action, JsonDocument& _document, ot::MessageType _messageType);
60
67 std::string dispatch(const std::string& _action, JsonDocument& _document, bool& _handlerFound, ot::MessageType _messageType);
68
77 std::string dispatchLocked(const std::string& _action, JsonDocument& _document, bool& _handlerFound, ot::MessageType _messageType);
78
79 private:
80
81 std::map<std::string, ActionHandleConnectorBase*> m_data;
82 std::mutex m_mutex;
83
85 virtual ~ActionDispatcher();
86 };
87}
#define OT_COMMUNICATION_API_EXPORT
Definition CommunicationAPIExport.h:6
This file contains defines that may be used simplyfy class creation.
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
The ActionDispatcher is used to dispatch inbound messages and forward them to their corresponding [Ac...
Definition ActionDispatcher.h:29
Base class for action handler connectors. A action handle connector has a set of actions.
Definition ActionHandleConnectorBase.h:24
JSON document.
Definition JSON.h:276
Definition Connector.h:8
MessageType
The message types describes how a message should be delivered.
Definition CommunicationTypes.h:10