2 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef HOMESCREEN_CLIENTMANAGER_H
18 #define HOMESCREEN_CLIENTMANAGER_H
23 #include <unordered_map>
24 #include "hs-helper.h"
25 #include "hs-client.h"
27 typedef struct HS_ClientCtxt
30 HS_ClientCtxt(const char *appid)
37 class HS_ClientManager {
40 ~HS_ClientManager() = default;
41 HS_ClientManager(HS_ClientManager const &) = delete;
42 HS_ClientManager &operator=(HS_ClientManager const &) = delete;
43 HS_ClientManager(HS_ClientManager &&) = delete;
44 HS_ClientManager &operator=(HS_ClientManager &&) = delete;
46 static HS_ClientManager* instance(void);
48 int handleRequest(afb_req_t request, const char *verb, const char *appid = nullptr);
49 void removeClientCtxt(void *data); // don't use, internal only
52 HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
53 HS_Client* addClient(afb_req_t req, std::string appid);
54 void removeClient(std::string appid);
57 static HS_ClientManager* me;
58 std::unordered_map<std::string, HS_Client*> client_list;
59 std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
63 #endif // HOMESCREEN_CLIENTMANAGER_H