Expand WMAction
[apps/agl-service-windowmanager.git] / src / applist.hpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef ALLOCATE_LIST_HPP
18 #define ALLOCATE_LIST_HPP
19 #include <vector>
20 #include <string>
21 #include <map>
22 #include <memory>
23 //#include <experimental/optional>
24 #include "windowmanager-client.hpp"
25 #include "request.hpp"
26
27 namespace wm {
28
29 /* using std::experimental::nullopt;
30 using std::experimental::optional; */
31
32 class  AppList {
33 public:
34     AppList();
35     virtual ~AppList();
36     AppList(const AppList &obj) = delete;
37
38     // Client Database Interface
39     void addClient(const std::string &appid, const std::string &role);
40     void removeClient(const std::string &appid);
41     bool contains(const std::string &appid);
42     int  countClient();
43     std::shared_ptr<WMClient> lookUpClient(const std::string &appid);
44
45     // Request Interface
46     unsigned currentSequenceNumber();
47     unsigned getSequenceNumber(const std::string &appid);
48     unsigned addAllocateRequest(WMRequest req);
49     /* TODO: consider, which is better WMClient or std::string appid?
50     if appid is key to manage resources, it is better to select std::string
51     otherwise WMClient is better, IMO */
52     bool     requestFinished();
53     bool     setAction(unsigned req_num, const struct WMAction &action);
54     bool     setAction(unsigned req_num, const std::string &appid, const std::string &role, const std::string &area, bool visible = true);
55     bool     setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role);
56     bool     endDrawFullfilled(unsigned req_num);
57     void     removeRequest(unsigned req_num);
58     void     next();
59     bool     haveRequest();
60
61     struct WMTrigger getRequest(unsigned req_num);
62     const std::vector<struct WMAction>& getActions(unsigned req_num);
63
64     void    client_dump();
65     void    req_dump();
66
67 private:
68   std::vector<WMRequest> req_list;
69   std::unordered_map<std::string, std::shared_ptr<WMClient>> client_list;
70   unsigned current_seq;
71 };
72
73 }
74 #endif // ALLOCATE_LIST_HPP