License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-condition-functions.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_FUNCTIONS_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_FUNCTIONS_H__
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 // INTERNAL INCLUDES
22 #include <dali/public-api/object/property-value.h>
23 #include <dali/internal/update/common/scene-graph-property-notification.h>
24
25 // OTHER CONDITITION INCLUDES
26 #include <dali/internal/update/common/property-condition-step-functions.h>
27 #include <dali/internal/update/common/property-condition-variable-step-functions.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 class ProxyObject;
36 class PropertyNotification;
37
38 namespace SceneGraph
39 {
40
41 // LessThan ///////////////////////////////////////////////////////////////////
42
43 /**
44  * LessThan condition class,
45  * Checks if a Property is "Less Than" the argument:
46  *
47  * bool       => false (0.0) or true (1.0) is less than arg0.
48  * float      => value is less than arg0.
49  * Vector2    => 2 dimensional length of vector is less than arg0.
50  * Vector3    => 3 dimensional length of vector is less than arg0.
51  * Vector4    => 4 dimensional length of vector is less than arg0.
52  * Default    => return false.
53  */
54 class LessThan
55 {
56
57 public:
58
59   /**
60    * @return function pointer to the correct condition function, based on
61    * the type of value being examined.
62    */
63   static ConditionFunction GetFunction(Property::Type valueType);
64
65 private:
66
67   /**
68    * Checks if bool is LessThan
69    * @param[in] value The value being examined.
70    * @param[in] arg The supplied arguments for the condition.
71    * @return Condition result (true if condition met, false if not)
72    */
73   static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
74
75   /**
76    * Checks if float is LessThan
77    * @param[in] value The value being examined.
78    * @param[in] arg The supplied arguments for the condition.
79    * @return Condition result (true if condition met, false if not)
80    */
81   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
82
83   /**
84    * Checks if Vector2.Length() is LessThan
85    * @param[in] value The value being examined.
86    * @param[in] arg The supplied arguments for the condition.
87    * @return Condition result (true if condition met, false if not)
88    */
89   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
90
91   /**
92    * Checks if Vector3.Length() is LessThan
93    * @param[in] value The value being examined.
94    * @param[in] arg The supplied arguments for the condition.
95    * @return Condition result (true if condition met, false if not)
96    */
97   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
98
99   /**
100    * Checks if Vector4.Length() is LessThan
101    * @param[in] value The value being examined.
102    * @param[in] arg The supplied arguments for the condition.
103    * @return Condition result (true if condition met, false if not)
104    */
105   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
106
107   /**
108    * Default check for other types
109    * @param[in] value The value being examined.
110    * @param[in] arg The supplied arguments for the condition.
111    * @return Condition result (true if condition met, false if not)
112    */
113   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
114
115 };
116
117 // GreaterThan ////////////////////////////////////////////////////////////////
118
119 /**
120  * GreaterThan condition class,
121  * Checks if a Property is "Greater Than" the argument:
122  *
123  * bool       => false (0.0) or true (1.0) is greater than arg0.
124  * float      => value is greater than arg0.
125  * Vector2    => 2 dimensional length of vector is greater than arg0.
126  * Vector3    => 3 dimensional length of vector is greater than arg0.
127  * Vector4    => 4 dimensional length of vector is greater than arg0.
128  * Default    => return false.
129  */
130 class GreaterThan
131 {
132
133 public:
134
135   /**
136    * @returns function pointer to the correct condition function, based on
137    * the type of value being examined.
138    */
139   static ConditionFunction GetFunction(Property::Type valueType);
140
141 private:
142
143   /**
144    * Checks if bool is GreaterThan
145    * @param[in] value The value being examined.
146    * @param[in] arg The supplied arguments for the condition.
147    * @return Condition result (true if condition met, false if not)
148    */
149   static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
150
151   /**
152    * Checks if float is GreaterThan
153    * @param[in] value The value being examined.
154    * @param[in] arg The supplied arguments for the condition.
155    * @return Condition result (true if condition met, false if not)
156    */
157   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
158
159   /**
160    * Checks if Vector2.Length() is GreaterThan
161    * @param[in] value The value being examined.
162    * @param[in] arg The supplied arguments for the condition.
163    * @return Condition result (true if condition met, false if not)
164    */
165   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
166
167   /**
168    * Checks if Vector3.Length() is GreaterThan
169    * @param[in] value The value being examined.
170    * @param[in] arg The supplied arguments for the condition.
171    * @return Condition result (true if condition met, false if not)
172    */
173   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
174
175   /**
176    * Checks if Vector4.Length() is GreaterThan
177    * @param[in] value The value being examined.
178    * @param[in] arg The supplied arguments for the condition.
179    * @return Condition result (true if condition met, false if not)
180    */
181   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
182
183   /**
184    * Default check for other types.
185    * @param[in] value The value being examined.
186    * @param[in] arg The supplied arguments for the condition.
187    * @return Condition result (true if condition met, false if not)
188    */
189   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
190
191 };
192
193 // Inside /////////////////////////////////////////////////////////////////////
194
195 /**
196  * Inside condition class,
197  * Checks if a Property is "Inside" the two arguments:
198  *
199  * bool       => false (0.0) or true (1.0) is inside arg0.
200  * float      => value is between arg0 and arg1.
201  * Vector2    => 2 dimensional length of vector is between arg0 and arg1.
202  * Vector3    => 3 dimensional length of vector is between arg0 and arg1.
203  * Vector4    => 4 dimensional length of vector is between arg0 and arg1.
204  * Default    => return false.
205  */
206 class Inside
207 {
208
209 public:
210
211   /**
212    * @return function pointer to the correct condition function, based on
213    * the type of value being examined.
214    */
215   static ConditionFunction GetFunction(Property::Type valueType);
216
217 private:
218
219   /**
220    * Checks if bool is Inside
221    * @param[in] value The value being examined.
222    * @param[in] arg The supplied arguments for the condition.
223    * @return Condition result (true if condition met, false if not)
224    */
225   static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
226
227   /**
228    * Checks if float is Inside
229    * @param[in] value The value being examined.
230    * @param[in] arg The supplied arguments for the condition.
231    * @return Condition result (true if condition met, false if not)
232    */
233   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
234
235   /**
236    * Checks if Vector2.Length() is Inside
237    * @param[in] value The value being examined.
238    * @param[in] arg The supplied arguments for the condition.
239    * @return Condition result (true if condition met, false if not)
240    */
241   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
242
243   /**
244    * Checks if Vector3.Length() is Inside
245    * @param[in] value The value being examined.
246    * @param[in] arg The supplied arguments for the condition.
247    * @return Condition result (true if condition met, false if not)
248    */
249   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
250
251   /**
252    * Checks if Vector4.Length() is Inside
253    * @param[in] value The value being examined.
254    * @param[in] arg The supplied arguments for the condition.
255    * @return Condition result (true if condition met, false if not)
256    */
257   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
258
259   /**
260    * Default check for other types.
261    * @param[in] value The value being examined.
262    * @param[in] arg The supplied arguments for the condition.
263    * @return Condition result (true if condition met, false if not)
264    */
265   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
266
267 };
268
269 // Outside ////////////////////////////////////////////////////////////////////
270
271 /**
272  * Outside condition class,
273  * Checks if a Property is "Outside" the two arguments:
274  *
275  * bool       => false (0.0) or true (1.0) is outside arg0.
276  * float      => value is outside arg0 and arg1.
277  * Vector2    => 2 dimensional length of vector is outside arg0 and arg1.
278  * Vector3    => 3 dimensional length of vector is outside arg0 and arg1.
279  * Vector4    => 4 dimensional length of vector is outside arg0 and arg1.
280  * Default    => return false.
281  */
282 class Outside
283 {
284
285 public:
286
287   /**
288    * @return function pointer to the correct condition function, based on
289    * the type of value being examined.
290    */
291   static ConditionFunction GetFunction(Property::Type valueType);
292
293 private:
294
295   /**
296    * Checks if bool is Outside
297    * @param[in] value The value being examined.
298    * @param[in] arg The supplied arguments for the condition.
299    * @return Condition result (true if condition met, false if not)
300    */
301   static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
302
303   /**
304    * Checks if float is Outside
305    * @param[in] value The value being examined.
306    * @param[in] arg The supplied arguments for the condition.
307    * @return Condition result (true if condition met, false if not)
308    */
309   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
310
311   /**
312    * Checks if Vector2.Length() is Outside
313    * @param[in] value The value being examined.
314    * @param[in] arg The supplied arguments for the condition.
315    * @return Condition result (true if condition met, false if not)
316    */
317   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
318
319   /**
320    * Checks if Vector3.Length() is Outside
321    * @param[in] value The value being examined.
322    * @param[in] arg The supplied arguments for the condition.
323    * @return Condition result (true if condition met, false if not)
324    */
325   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
326
327   /**
328    * Checks if Vector4.Length() is Outside
329    * @param[in] value The value being examined.
330    * @param[in] arg The supplied arguments for the condition.
331    * @return Condition result (true if condition met, false if not)
332    */
333   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
334
335   /**
336    * Default check for other types.
337    * @param[in] value The value being examined.
338    * @param[in] arg The supplied arguments for the condition.
339    * @return Condition result (true if condition met, false if not)
340    */
341   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
342
343 };
344
345 } // namespace SceneGraph
346
347 } // namespace Internal
348
349 } // namespace Dali
350
351 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_FUNCTIONS_H__