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 2024 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_CLIENT_CONTROLLER_H_
21 : #define FIREBOLT_RIALTO_CLIENT_I_CLIENT_CONTROLLER_H_
22 :
23 : #include <functional>
24 : #include <memory>
25 : #include <stdint.h>
26 :
27 : #include "IClientLogHandler.h"
28 : #include "IControlClient.h"
29 : #include "ISharedMemoryHandle.h"
30 :
31 : namespace firebolt::rialto::client
32 : {
33 : class IClientController;
34 :
35 : /**
36 : * @brief IClientController accessor class definition.
37 : */
38 : class IClientControllerAccessor
39 : {
40 : public:
41 1 : virtual ~IClientControllerAccessor() = default;
42 : IClientControllerAccessor(const IClientControllerAccessor &) = delete;
43 : IClientControllerAccessor &operator=(const IClientControllerAccessor &) = delete;
44 : IClientControllerAccessor(IClientControllerAccessor &&) = delete;
45 : IClientControllerAccessor &operator=(IClientControllerAccessor &&) = delete;
46 :
47 : /**
48 : * @brief Get a IClientControllerAccessor instance.
49 : *
50 : * @retval the accessor instance
51 : */
52 : static IClientControllerAccessor &instance();
53 :
54 : /**
55 : * @brief Get ClientController object.
56 : *
57 : * @retval the reference to ClientController singleton object
58 : */
59 : virtual IClientController &getClientController() const = 0;
60 :
61 : protected:
62 : IClientControllerAccessor() = default;
63 : };
64 :
65 : /**
66 : * @brief The definition of the IClientController interface.
67 : *
68 : * This interface defines the internal API querying shared memory.
69 : */
70 : class IClientController
71 : {
72 : public:
73 170 : IClientController() = default;
74 170 : virtual ~IClientController() = default;
75 :
76 : IClientController(const IClientController &) = delete;
77 : IClientController &operator=(const IClientController &) = delete;
78 : IClientController(IClientController &&) = delete;
79 : IClientController &operator=(IClientController &&) = delete;
80 :
81 : /**
82 : * @brief Gets the handle to the mapped shared memory.
83 : *
84 : * @retval shared pointer to shm handle.
85 : */
86 : virtual std::shared_ptr<ISharedMemoryHandle> getSharedMemoryHandle() = 0;
87 :
88 : /**
89 : * @brief Register a client notify when the shared buffer changes.
90 : *
91 : * @param[in] client : Client to register.
92 : * @param[out] appState : Current application state
93 : *
94 : * @retval true on success, false otherwise.
95 : */
96 : virtual bool registerClient(std::weak_ptr<IControlClient> client, ApplicationState &appState) = 0;
97 :
98 : /**
99 : * @brief Unregister a client.
100 : *
101 : * @param[in] client : Client to unregister.
102 : *
103 : * @retval true on success, false otherwise.
104 : */
105 : virtual bool unregisterClient(std::weak_ptr<IControlClient> client) = 0;
106 : };
107 :
108 : }; // namespace firebolt::rialto::client
109 :
110 : #endif // FIREBOLT_RIALTO_CLIENT_I_CLIENT_CONTROLLER_H_
|