Repository navigation
Expand file tree
/
Copy pathIIpcService.h
More file actions
194 lines (172 loc) · 5.89 KB
/
Copy pathIIpcService.h
File metadata and controls
194 lines (172 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 Sky UK
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* IIpcService.h
*
* Created on: 3 Jun 2015
* Author: riyadh
*/
#ifndef AI_IPC_IIPCSERVICE_H
#define AI_IPC_IIPCSERVICE_H
#include "IpcCommon.h"
#include <memory>
#include <string>
#include <set>
namespace AI_IPC
{
/**
* @brief IPC service that enables us to invoke remote method and emit signals as well as to handle incoming method calls and received signals.
*/
class IIpcService
{
public:
virtual ~IIpcService() = default;
/**
* @brief Returns true if we initialised ourselves successfully
*
* @returns True if the service was initialised successfully. False if we failed to initialise
*/
virtual bool isValid() const = 0;
/**
* @brief Invoke a method and get reply asynchronously
*
* @parameter[in] method Method definition
* @parameter[in] args Method arguments
* @parameter[in] timeoutMs Timeout in milliseconds, -1 for default (30 seconds)
*
* @returns On success: Shared pointer pointing to a reply getter to receive reply asynchronously.
* @returns On failure: Empty shared pointer.
*/
virtual std::shared_ptr<IAsyncReplyGetter> invokeMethod(const Method& method, const VariantList& args, int timeoutMs = -1) = 0;
/**
* @brief Invoke a method and get reply synchronously
*
* @parameter[in] method Method definition
* @parameter[in] args Method arguments
* @parameter[in] replyArgs Reply return by the method call
* @parameter[in] timeoutMs Timeout in milliseconds, -1 for default (30 seconds)
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool invokeMethod(const Method& method, const VariantList& args, VariantList& replyArgs, int timeoutMs = -1) = 0;
/**
* @brief Emit a signal
*
* @parameter[in] signal Signal definition
* @parameter[in] args Signal arguments/data
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool emitSignal(const Signal& signal, const VariantList& args) = 0;
/**
* @brief Register a method handler
*
* @parameter[in] method Method definition
* @parameter[in] handler Method handler
*
* @returns On success: Registration ID.
* @returns On failure: Empty string.
*/
virtual std::string registerMethodHandler(const Method& method, const MethodHandler& handler) = 0;
/**
* @brief Register a signal handler
*
* @parameter[in] method Signal definition
* @parameter[in] handler Signal handler
*
* @returns On success: Registration ID.
* @returns On failure: Empty string.
*/
virtual std::string registerSignalHandler(const Signal& signal, const SignalHandler& handler) = 0;
/**
* @brief Unregister a method or signal handler
*
* @parameter[in] regId Registration Id
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool unregisterHandler(const std::string& regId) = 0;
/**
* @brief Enables monitor mode for the service
*
* @parameter[in] matchRules Optional set of match rules for monitor mode, can be empty
* @parameter[in] handler Handler callback for all events received in monitor mode
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool enableMonitor(const std::set<std::string>& matchRules, const MonitorHandler& handler) = 0;
/**
* @brief Disables monitor mode for the service
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool disableMonitor() = 0;
/**
* @brief Checks if the given service name is currently registered on the bus.
*
* @parameter[in] serviceName The name of the service to look for
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool isServiceAvailable(const std::string& serviceName) const = 0;
/**
* @brief Flushes all messages out
*
* This method ensures that any message or signal handlers queued before this function was called are
* processed before the function returns.
*
* For obvious reasons do not hold any lock that a handler might need while calling this function.
*/
virtual void flush() = 0;
/**
* @brief Start IPC service
*
* It needs to be invoked to start the event dispatcher, which is required to handle method and signals,
* as well as to get method call reply.
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool start() = 0;
/**
* @brief Stop IPC service
*
* The event dispatcher thread will be terminated.
*
* @returns On success: True.
* @returns On failure: False.
*/
virtual bool stop() = 0;
/**
* @brief Returns the dbus address the service is using.
*
* Note the address is formatted like a dbus address and is NOT just the path to the unix socket.
*
* @returns The dbus address.
*/
virtual std::string getBusAddress() const = 0;
};
}
#endif /* AI_IPC_IIPCSERVICE_H */