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