Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
DobbyIPCUtils.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: DobbyUtils.h
21 *
22 */
23#ifndef DOBBYIPCUTILS_H
24#define DOBBYIPCUTILS_H
25
26#include "IDobbyIPCUtils.h"
27
28#include <IIpcService.h>
29
30#include <map>
31#include <mutex>
32#include <functional>
33
34class DobbyIpcBus;
35
36// -----------------------------------------------------------------------------
43class DobbyIPCUtils : public virtual IDobbyIPCUtils
44{
45public:
46 DobbyIPCUtils(const std::string &systemDbusAddress,
47 const std::shared_ptr<AI_IPC::IIpcService> &systemIpcService);
48 ~DobbyIPCUtils() final;
49
50public:
51 std::shared_ptr<AI_IPC::IAsyncReplyGetter> ipcInvokeMethod(const BusType &bus,
52 const AI_IPC::Method &method,
53 const AI_IPC::VariantList &args,
54 int timeoutMs) const override;
55
56 bool ipcInvokeMethod(const BusType &bus,
57 const AI_IPC::Method &method,
58 const AI_IPC::VariantList &args,
59 AI_IPC::VariantList &replyArgs) const override;
60
61 bool ipcEmitSignal(const BusType &bus,
62 const AI_IPC::Signal &signal,
63 const AI_IPC::VariantList &args) const override;
64
65 bool ipcServiceAvailable(const BusType &bus,
66 const std::string &serviceName) const override;
67
69 const std::string &serviceName,
70 const std::function<void(bool)> &handlerFunc) override;
71
72 int ipcRegisterSignalHandler(const BusType &bus,
73 const AI_IPC::Signal &signal,
74 const AI_IPC::SignalHandler &handlerFunc) override;
75
76 void ipcUnregisterHandler(const BusType &bus,
77 int handlerId) override;
78
79 std::string ipcDbusAddress(const BusType &bus) const override;
80
81 std::string ipcDbusSocketPath(const BusType &bus) const override;
82
83public:
84 bool setAIDbusAddress(bool privateBus, const std::string &address);
85
86private:
87 std::shared_ptr<DobbyIpcBus> getIpcBus(const BusType &bus) const;
88
89 std::map<BusType, std::shared_ptr<DobbyIpcBus>> mIpcBuses;
90};
91
92#endif // !defined(DOBBYIPCUTILS_H)
Utility methods for IPC in Dobby.
Definition DobbyIPCUtils.h:44
bool ipcServiceAvailable(const BusType &bus, const std::string &serviceName) const override
Queries if the given service is available on the bus.
Definition DobbyIPCUtils.cpp:339
void ipcUnregisterHandler(const BusType &bus, int handlerId) override
Unregisters either a service or signal handler.
Definition DobbyIPCUtils.cpp:245
int ipcRegisterSignalHandler(const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::SignalHandler &handlerFunc) override
Registers a callback function that will be called when the given signal is received on the bus.
Definition DobbyIPCUtils.cpp:186
bool ipcEmitSignal(const BusType &bus, const AI_IPC::Signal &signal, const AI_IPC::VariantList &args) const override
Sends out a signal over dbus.
Definition DobbyIPCUtils.cpp:318
bool setAIDbusAddress(bool privateBus, const std::string &address)
Sets the dbus address for one of the AI dbus-daemons.
Definition DobbyIPCUtils.cpp:95
std::string ipcDbusSocketPath(const BusType &bus) const override
Returns just the path to the socket for the dbus daemon.
Definition DobbyIPCUtils.cpp:156
std::shared_ptr< DobbyIpcBus > getIpcBus(const BusType &bus) const
Utility function to simply return the bus object associated with the given bus id.
Definition DobbyIPCUtils.cpp:73
std::string ipcDbusAddress(const BusType &bus) const override
Returns complete address to the dbus daemon.
Definition DobbyIPCUtils.cpp:134
std::shared_ptr< AI_IPC::IAsyncReplyGetter > ipcInvokeMethod(const BusType &bus, const AI_IPC::Method &method, const AI_IPC::VariantList &args, int timeoutMs) const override
Invokes the ipc method.
Definition DobbyIPCUtils.cpp:269
int ipcRegisterServiceHandler(const BusType &bus, const std::string &serviceName, const std::function< void(bool)> &handlerFunc) override
Registers a callback function that will be called when the given service is added or removed from the...
Definition DobbyIPCUtils.cpp:223
Wraps an IPC service object on a given bus.
Definition DobbyIpcBus.h:58
Definition IDobbyIPCUtils.h:47
BusType
The type of dbus to call methods on / emit signals.
Definition IDobbyIPCUtils.h:60
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