001134a8f88c8b26d92ad285157f6d0098cf66cf
[apps/agl-service-windowmanager.git] / src / wm_layer.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 WM_LAYERS_H
18 #define WM_LAYERS_H
19
20 #include <string>
21 #include <vector>
22 #include <unordered_map>
23 #include <memory>
24 #include "wm_error.hpp"
25
26 struct json_object;
27
28 namespace wm
29 {
30
31 class WMClient;
32 class LayerState
33 {
34   public:
35     LayerState();
36     ~LayerState() = default;
37     void attachIdToArea(const std::string& area, const WMClient&);
38     const std::unordered_map<std::string, std::string> popCurrentState();
39     const std::unordered_map<std::string, std::string> getCurrentState();
40     const std::vector<unsigned> getIviIdList();
41
42   private:
43     std::vector<unsigned> render_order;
44     std::unordered_map<std::string, std::string> area2appid;
45 };
46
47 class LayerSetting
48 {
49   public:
50     enum MANAGEMENT_TYPE
51     {
52         TILE,
53         STACK
54     };
55
56     explicit LayerSetting(const std::string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end);
57     ~LayerSetting() = default;
58
59     const std::string& layerName() { return this->name; }
60     MANAGEMENT_TYPE layerType() { return this->type; };
61     void setRoleList(const std::string& role);
62     void appendArea(const std::string& area);
63     unsigned idBegin() { return this->id_begin; }
64     unsigned idEnd()   { return this->id_end; }
65     unsigned getNewLayerID(const std::string& role);
66     void removeLayerID(unsigned id);
67
68 /*     unsigned getNewID(const std::string& role);
69     void remove(unsigned ivi_layer_id);
70     void clear();
71     bool attach(unsigned ivi_layer_id, const std::string& area);
72     void stack(unsigned ivi_layer_id, const std::string& area);
73     bool updateRenderOrder(const std::vector<unsigned> list); */
74
75   private:
76     std::string name = ""; // Layer name
77     MANAGEMENT_TYPE type;
78     std::string role_list;
79     std::vector<std::string> area_list;
80     std::vector<unsigned>    id_list;
81     unsigned id_begin;
82     unsigned id_end;
83 };
84
85 class WMLayer
86 {
87   public:
88     WMLayer();
89     WMLayer(json_object* j);
90     ~WMLayer() = default;
91     unsigned getNewLayerID(const std::string& role);
92     LayerState getLayerState() const { return before_state; }
93     WMError setLayerState(const LayerState& l);
94     bool checkIDBelongTo(unsigned id);
95   private:
96     LayerState before_state;
97     LayerState state;
98     std::unique_ptr<LayerSetting> setting;
99 };
100
101 } // namespace wm
102
103 #endif // WM_LAYERS_H