Line data Source code
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 2022 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 : #ifndef FIREBOLT_RIALTO_CLIENT_I_IPC_CLIENT_H_
21 : #define FIREBOLT_RIALTO_CLIENT_I_IPC_CLIENT_H_
22 :
23 : #include <memory>
24 : #include <stdint.h>
25 : #include <string>
26 : #include <thread>
27 :
28 : #include <IBlockingClosure.h>
29 : #include <IIpcChannel.h>
30 : #include <IIpcControllerFactory.h>
31 :
32 : #include "IConnectionObserver.h"
33 :
34 : namespace firebolt::rialto::client
35 : {
36 : class IIpcClient;
37 :
38 : /**
39 : * @brief IIpcClient accessor class definition.
40 : */
41 : class IIpcClientAccessor
42 : {
43 : public:
44 1 : virtual ~IIpcClientAccessor() = default;
45 : IIpcClientAccessor(const IIpcClientAccessor &) = delete;
46 : IIpcClientAccessor &operator=(const IIpcClientAccessor &) = delete;
47 : IIpcClientAccessor(IIpcClientAccessor &&) = delete;
48 : IIpcClientAccessor &operator=(IIpcClientAccessor &&) = delete;
49 :
50 : /**
51 : * @brief Get a IControlIpcAccessor instance.
52 : *
53 : * @retval the accessor instance
54 : */
55 : static IIpcClientAccessor &instance();
56 :
57 : /**
58 : * @brief Get IpcClient object.
59 : *
60 : * @retval the reference to IpcClient singleton object
61 : */
62 : virtual IIpcClient &getIpcClient() const = 0;
63 :
64 : protected:
65 : IIpcClientAccessor() = default;
66 : };
67 :
68 : /**
69 : * @brief The definition of the IIpcClient interface.
70 : *
71 : * This interface defines the control ipc APIs that are used to communicate with the Rialto server.
72 : */
73 : class IIpcClient
74 : {
75 : public:
76 391 : IIpcClient() = default;
77 391 : virtual ~IIpcClient() = default;
78 :
79 : IIpcClient(const IIpcClient &) = delete;
80 : IIpcClient &operator=(const IIpcClient &) = delete;
81 : IIpcClient(IIpcClient &&) = delete;
82 : IIpcClient &operator=(IIpcClient &&) = delete;
83 :
84 : /**
85 : * @brief Gets a weak ptr to the Ipc channel created by the IpcClient.
86 : *
87 : * @retval the ipc channel weak ptr.
88 : */
89 : virtual std::weak_ptr<ipc::IChannel> getChannel() const = 0;
90 :
91 : /**
92 : * @brief Create the blocking closure to be passed to the RPC stubs.
93 : *
94 : * @retval the blocking closure or null on error.
95 : */
96 : virtual std::shared_ptr<ipc::IBlockingClosure> createBlockingClosure() = 0;
97 :
98 : /**
99 : * @brief Create the rpc controller to be passed to the RPC stubs.
100 : *
101 : * @retval the rpc controller or null on error.
102 : */
103 : virtual std::shared_ptr<google::protobuf::RpcController> createRpcController() = 0;
104 :
105 : /**
106 : * @brief Reconnect channel.
107 : *
108 : * @retval true on success.
109 : */
110 : virtual bool reconnect() = 0;
111 :
112 : /**
113 : * @brief Registers new connection observer.
114 : */
115 : virtual void registerConnectionObserver(const std::weak_ptr<IConnectionObserver> &observer) = 0;
116 : };
117 :
118 : }; // namespace firebolt::rialto::client
119 :
120 : #endif // FIREBOLT_RIALTO_CLIENT_I_IPC_CLIENT_H_
|