Updated all header files to new format
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / replacement.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H
2 #define DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/property-value.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/devel-api/builder/builder.h>
26 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 class TreeNode;
33 }
34
35 namespace Toolkit
36 {
37 namespace Internal
38 {
39 /*
40  * Supports template replacement functionality
41  *
42  */
43 class Replacement
44 {
45 public:
46   /*
47    * Constructor
48    */
49   Replacement();
50
51   /*
52    * Constructor with default and overriding map
53    *
54    * Make a deep copy of the tree.
55    * @param overrideMap The user overriding map
56    * @param defaultMap The default map to use
57    */
58   Replacement(const Property::Map& overrideMap, const Property::Map& defaultMap);
59
60   /*
61    * Constructor with default map
62    *
63    * Make a deep copy of the tree.
64    * @param overrideMap The user overriding map
65    */
66   Replacement(const Property::Map& defaultMap);
67
68   /* @brief Check node for a type
69    *
70    * @param node The TreeNode to check
71    * @return Optional value
72    */
73   OptionalString IsString(const TreeNode& node) const;
74
75   /* @brief Check node for a type
76    *
77    * @param node The TreeNode to check
78    * @return Optional value
79    */
80   OptionalBoolean IsBoolean(const TreeNode& node) const;
81
82   /* @brief Check node for a type
83    *
84    * @param node The TreeNode to check
85    * @return Optional value
86    */
87   OptionalFloat IsFloat(const TreeNode& node) const;
88
89   /* @brief Check node for a type
90    *
91    * @param node The TreeNode to check
92    * @return Optional value
93    */
94   OptionalInteger IsInteger(const TreeNode& node) const;
95
96   /* @brief Check node for a type
97    *
98    * @param node The TreeNode to check
99    * @return Optional value
100    */
101   OptionalVector2 IsVector2(const TreeNode& node) const;
102
103   /* @brief Check node for a type
104    *
105    * @param node The TreeNode to check
106    * @return Optional value
107    */
108   OptionalVector3 IsVector3(const TreeNode& node) const;
109
110   /* @brief Check node for a type
111    *
112    * @param node The TreeNode to check
113    * @return Optional value
114    */
115   OptionalVector4 IsVector4(const TreeNode& node) const;
116
117   /* @brief Check node for a type
118    *
119    * @param node The TreeNode to check
120    * @return Optional value
121    */
122   OptionalMatrix IsMatrix(const TreeNode& node) const;
123
124   /* @brief Check node for a type
125    *
126    * @param node The TreeNode to check
127    * @return Optional value
128    */
129   OptionalMatrix3 IsMatrix3(const TreeNode& node) const;
130
131   /* @brief Check node for a type
132    *
133    * @param node The TreeNode to check
134    * @return Optional value
135    */
136   OptionalRect IsRect(const TreeNode& node) const;
137
138   /* @brief Check node for a type
139    *
140    * @param node The TreeNode to check
141    * @return Optional value
142    */
143   OptionalExtents IsExtents(const TreeNode& node) const;
144
145   /* @brief Check node for a type
146    *
147    * @param child The optional child TreeNode
148    * @return Optional value
149    */
150   OptionalString IsString(OptionalChild child) const;
151
152   /* @brief Check node for a type
153    *
154    * @param child The optional child TreeNode
155    * @return Optional value
156    */
157   OptionalFloat IsFloat(OptionalChild child) const;
158
159   /* @brief Check node for a type
160    *
161    * @param child The optional child TreeNode
162    * @return Optional value
163    */
164   OptionalBoolean IsBoolean(OptionalChild child) const;
165
166   /* @brief Check node for a type
167    *
168    * @param child The optional child TreeNode
169    * @return Optional value
170    */
171   OptionalInteger IsInteger(OptionalChild child) const;
172
173   /* @brief Check node for a type
174    *
175    * @param child The optional child TreeNode
176    * @return Optional value
177    */
178   OptionalVector2 IsVector2(OptionalChild child) const;
179
180   /* @brief Check node for a type
181    *
182    * @param child The optional child TreeNode
183    * @return Optional value
184    */
185   OptionalVector3 IsVector3(OptionalChild child) const;
186
187   /* @brief Check node for a type
188    *
189    * @param child The optional child TreeNode
190    * @return Optional value
191    */
192   OptionalVector4 IsVector4(OptionalChild child) const;
193
194   /* @brief Check node for a type
195    *
196    * @param child The optional child TreeNode
197    * @return Optional value
198    */
199   OptionalMatrix IsMatrix(OptionalChild child) const;
200
201   /* @brief Check node for a type
202    *
203    * @param child The optional child TreeNode
204    * @return Optional value
205    */
206   OptionalMatrix3 IsMatrix3(OptionalChild child) const;
207
208   /* @brief Check node for a type
209    *
210    * @param child The optional child TreeNode
211    * @return Optional value
212    */
213   OptionalRect IsRect(OptionalChild child) const;
214
215   /* @brief Check node for a type
216    *
217    * @param child The optional child TreeNode
218    * @return Optional value
219    */
220   bool IsMap(OptionalChild child, Property::Value& out) const;
221
222   /* @brief Check node for a type
223    *
224    * @param child The optional child TreeNode
225    * @return Optional value
226    */
227   bool IsArray(OptionalChild child, Property::Value& out) const;
228
229   /* @brief Check node for a type
230    *
231    * @param child The optional child TreeNode
232    * @return Optional value
233    */
234   OptionalExtents IsExtents(OptionalChild child) const;
235
236 private:
237   // Overriding map (overrides the default map). The map is not owned.
238   const Property::Map* const mOverrideMap;
239
240   // Default map. The map is not owned.
241   const Property::Map* const mDefaultMap;
242
243   // compiler
244   // Replacement & operation=( Replacement& replacement );
245   // Replacement( const Replacement& copy );
246
247   // Returns the string if the node has a full replacement ie IMAGES if node is "{IMAGES}"
248   OptionalString HasFullReplacement(const TreeNode& node) const;
249
250   // Returns the property value for a full replacement from the maps
251   Property::Value GetFullReplacement(const std::string& replacementString) const;
252 };
253
254 } // namespace Internal
255
256 } // namespace Toolkit
257
258 } // namespace Dali
259
260 #endif // DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H