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_CONTROL_H_
21 : #define FIREBOLT_RIALTO_CLIENT_CONTROL_H_
22 :
23 : #include <memory>
24 : #include <string>
25 : #include <vector>
26 :
27 : #include "IClientController.h"
28 : #include "IControl.h"
29 : #include "IControlClient.h"
30 : #include "RialtoLogging.h"
31 :
32 : namespace firebolt::rialto::client
33 : {
34 : /**
35 : * @brief IControl factory class definition.
36 : */
37 : class ControlFactory : public IControlFactory
38 : {
39 : public:
40 1 : ControlFactory() = default;
41 1 : ~ControlFactory() override = default;
42 :
43 : std::shared_ptr<IControl> createControl() const override;
44 : /**
45 : * @brief Create the control factory object.
46 : *
47 : * @retval the control factory instance or null on error.
48 : */
49 : static std::shared_ptr<ControlFactory> createFactory();
50 : };
51 :
52 : /**
53 : * @brief The definition of the Control.
54 : */
55 : class Control : public IControl
56 : {
57 : public:
58 : /**
59 : * @brief The constructor.
60 : */
61 : explicit Control(IClientController &clientController);
62 :
63 : /**
64 : * @brief Virtual destructor.
65 : */
66 : ~Control() override;
67 :
68 : bool registerClient(std::weak_ptr<IControlClient> client, ApplicationState &appState) override;
69 :
70 : private:
71 : /**
72 : * @brief The control clients which have been registered with m_clientController
73 : * and are kept so that they can be unregistered upon destruction of this
74 : * object
75 : */
76 : std::vector<std::shared_ptr<IControlClient>> m_clientsToUnregister;
77 :
78 : /**
79 : * @brief The rialto client controller object.
80 : */
81 : IClientController &m_clientController;
82 : };
83 :
84 : }; // namespace firebolt::rialto::client
85 :
86 : #endif // FIREBOLT_RIALTO_CLIENT_CONTROL_H_
|