Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
IDobbyIPCUtils.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2016 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 /*
20  * File: IDobbyIPCUtils.h
21  *
22  */
23 #ifndef IDOBBYIPCUTILS_H
24 #define IDOBBYIPCUTILS_H
25 
26 #include <IIpcService.h>
27 
28 #include <cstdint>
29 #include <string>
30 #include <list>
31 #include <functional>
32 
33 #include <sys/types.h>
34 #include <sys/sysmacros.h>
35 
36 // -----------------------------------------------------------------------------
47 {
48 public:
49  virtual ~IDobbyIPCUtils() = default;
50 
51 public:
52  // -------------------------------------------------------------------------
59  enum class BusType
60  {
61  NoneBus,
62  SystemBus,
63  AIPrivateBus,
64  AIPublicBus
65  };
66 
67  // -------------------------------------------------------------------------
77  virtual std::shared_ptr<AI_IPC::IAsyncReplyGetter> ipcInvokeMethod(const BusType &bus,
78  const AI_IPC::Method &method,
79  const AI_IPC::VariantList &args,
80  int timeoutMs = -1) const = 0;
81 
82  // -------------------------------------------------------------------------
95  virtual bool ipcInvokeMethod(const BusType &bus,
96  const AI_IPC::Method &method,
97  const AI_IPC::VariantList &args,
98  AI_IPC::VariantList &replyArgs) const = 0;
99 
100  // -------------------------------------------------------------------------
112  virtual bool ipcEmitSignal(const BusType &bus,
113  const AI_IPC::Signal &signal,
114  const AI_IPC::VariantList &args) const = 0;
115 
116  // -------------------------------------------------------------------------
127  virtual bool ipcServiceAvailable(const BusType &bus,
128  const std::string &serviceName) const = 0;
129 
130  // -------------------------------------------------------------------------
156  virtual int ipcRegisterServiceHandler(const BusType &bus,
157  const std::string &serviceName,
158  const std::function<void(bool)> &handlerFunc) = 0;
159 
160  // -------------------------------------------------------------------------
176  virtual int ipcRegisterSignalHandler(const BusType &bus,
177  const AI_IPC::Signal &signal,
178  const AI_IPC::SignalHandler &handlerFunc) = 0;
179 
180  // -------------------------------------------------------------------------
191  virtual void ipcUnregisterHandler(const BusType &bus, int handlerId) = 0;
192 
193  // -------------------------------------------------------------------------
202  virtual std::string ipcDbusAddress(const BusType &bus) const = 0;
203 
204  // -------------------------------------------------------------------------
213  virtual std::string ipcDbusSocketPath(const BusType &bus) const = 0;
214 };
215 
216 #endif // !defined(IDOBBYIPCUTILS_H)
Definition: IDobbyIPCUtils.h:47
virtual std::string ipcDbusSocketPath(const BusType &bus) const =0
Returns just the path to the socket for the dbus daemon.
virtual int ipcRegisterServiceHandler(const BusType &bus, const std::string &serviceName, const std::function< void(bool)> &handlerFunc)=0
Registers a callback function that will be called when the given service is added or removed from the...
virtual bool ipcInvokeMethod(const BusType &bus, const AI_IPC::Method &method, const AI_IPC::VariantList &args, AI_IPC::VariantList &replyArgs) const =0
Invokes the ipc method.
virtual void ipcUnregisterHandler(const BusType &bus, int handlerId)=0
Unregisters either a service or signal handler.
virtual std::string ipcDbusAddress(const BusType &bus) const =0
Returns complete address to the dbus daemon.
virtual std::shared_ptr< AI_IPC::IAsyncReplyGetter > ipcInvokeMethod(const BusType &bus, const AI_IPC::Method &method, const AI_IPC::VariantList &args, int timeoutMs=-1) const =0
Wrappers around the IPC services in the Dobby daemon.
virtual bool ipcEmitSignal(const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::VariantList &args) const =0
Sends out a signal over dbus.
virtual int ipcRegisterSignalHandler(const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::SignalHandler &handlerFunc)=0
Registers a callback function that will be called when the given signal is received on the bus.
BusType
The type of dbus to call methods on / emit signals.
Definition: IDobbyIPCUtils.h:60
virtual bool ipcServiceAvailable(const BusType &bus, const std::string &serviceName) const =0
Queries if the given service is available on the bus.
Method identified by a service, object, interface and method name itself.
Definition: IpcCommon.h:90
Method identified by object, interface and signal name itself.
Definition: IpcCommon.h:105