Forgot adding new files
[apps/agl-service-windowmanager-2017.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 namespace wm
27 {
28
29 class LayerState
30 {
31   public:
32     LayerState();
33     ~LayerState() = default;
34   private:
35     std::vector<unsigned> _ivi_layer_id_list;
36     std::unordered_map<std::string, unsigned> area2ivi_layer_id;
37     // std::map<std::string, unsigned> _render_order;
38 };
39
40 class LayerSetting
41 {
42   public:
43     enum MANAGEMENT_TYPE
44     {
45         TILE,
46         STACK
47     };
48
49     explicit LayerSetting(const std::string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end);
50     ~LayerSetting() = default;
51
52     const std::string& layerName() { return this->name; }
53     MANAGEMENT_TYPE layerType() { return this->type; };
54     void appendRole(const std::string& role);
55     void appendArea(const std::string& area);
56     unsigned idBegin() { return this->id_begin; }
57     unsigned idEnd()   { return this->id_end; }
58     unsigned getNewLayerID(const std::string& role);
59     void removeLayerID(unsigned id);
60
61 /*     unsigned getNewID(const std::string& role);
62     void remove(unsigned ivi_layer_id);
63     void clear();
64     bool attach(unsigned ivi_layer_id, const std::string& area);
65     void stack(unsigned ivi_layer_id, const std::string& area);
66     bool updateRenderOrder(const std::vector<unsigned> list); */
67
68   private:
69     std::string name = ""; // Layer name
70     MANAGEMENT_TYPE type;
71     std::vector<std::string> role_list;
72     std::vector<std::string> area_list;
73     std::vector<unsigned>    id_list;
74     unsigned id_begin;
75     unsigned id_end;
76 };
77
78 class WMLayer
79 {
80   public:
81     WMLayer();
82     ~WMLayer() = default;
83     unsigned getNewLayerID(const std::string& role);
84     LayerState getLayerState() const { return before_state; }
85     WMError setLayerState(const LayerState& l);
86     bool checkIDBelongTo(unsigned id);
87   private:
88     LayerState before_state;
89     LayerState state;
90     std::unique_ptr<LayerSetting> setting;
91 };
92
93 } // namespace wm
94
95 #endif // WM_LAYERS_H