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 RIALTO_SERVERMANAGER_IPC_CONTROLLER_H_
21 : #define RIALTO_SERVERMANAGER_IPC_CONTROLLER_H_
22 :
23 : #include "Client.h"
24 : #include "IController.h"
25 : #include <map>
26 : #include <memory>
27 : #include <mutex>
28 : #include <string>
29 :
30 : namespace rialto::servermanager
31 : {
32 : namespace common
33 : {
34 : class ISessionServerAppManager;
35 : } // namespace common
36 : } // namespace rialto::servermanager
37 :
38 : namespace rialto::servermanager::ipc
39 : {
40 : class Controller : public IController
41 : {
42 : public:
43 : explicit Controller(std::unique_ptr<common::ISessionServerAppManager> &sessionServerAppManager);
44 34 : virtual ~Controller() = default;
45 :
46 : Controller(const Controller &) = delete;
47 : Controller(Controller &&) = delete;
48 : Controller &operator=(const Controller &) = delete;
49 : Controller &operator=(Controller &&) = delete;
50 :
51 : bool createClient(int serverId, int appMgmtSocket) override;
52 : void removeClient(int serverId) override;
53 : bool performSetConfiguration(int serverId, const firebolt::rialto::common::SessionServerState &initialState,
54 : const std::string &socketName, const std::string &clientDisplayName,
55 : const firebolt::rialto::common::MaxResourceCapabilitites &maxResource,
56 : const unsigned int socketPermissions, const std::string &socketOwner,
57 : const std::string &socketGroup, const std::string &appName) override;
58 : bool performPing(int serverId, int pingId) override;
59 : bool performSetState(int serverId, const firebolt::rialto::common::SessionServerState &state) override;
60 : bool setLogLevels(const service::LoggingLevels &logLevels) const override;
61 :
62 : private:
63 : mutable std::mutex m_clientMutex;
64 : std::unique_ptr<common::ISessionServerAppManager> &m_sessionServerAppManager;
65 : std::map<int, std::unique_ptr<Client>> m_clients;
66 : };
67 : } // namespace rialto::servermanager::ipc
68 :
69 : #endif // RIALTO_SERVERMANAGER_IPC_CONTROLLER_H_
|