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