Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[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 Object;
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 integer 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
82
83   /**
84    * Checks if unsigned integer 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 EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
90
91   /**
92    * Checks if float 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 EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
98
99   /**
100    * Checks if Vector2.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 EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
106
107   /**
108    * Checks if Vector3.Length() is LessThan
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 EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
114
115   /**
116    * Checks if Vector4.Length() is LessThan
117    * @param[in] value The value being examined.
118    * @param[in] arg The supplied arguments for the condition.
119    * @return Condition result (true if condition met, false if not)
120    */
121   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
122
123   /**
124    * Default check for other types
125    * @param[in] value The value being examined.
126    * @param[in] arg The supplied arguments for the condition.
127    * @return Condition result (true if condition met, false if not)
128    */
129   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
130
131 };
132
133 // GreaterThan ////////////////////////////////////////////////////////////////
134
135 /**
136  * GreaterThan condition class,
137  * Checks if a Property is "Greater Than" the argument:
138  *
139  * bool       => false (0.0) or true (1.0) is greater than arg0.
140  * float      => value is greater than arg0.
141  * Vector2    => 2 dimensional length of vector is greater than arg0.
142  * Vector3    => 3 dimensional length of vector is greater than arg0.
143  * Vector4    => 4 dimensional length of vector is greater than arg0.
144  * Default    => return false.
145  */
146 class GreaterThan
147 {
148
149 public:
150
151   /**
152    * @returns function pointer to the correct condition function, based on
153    * the type of value being examined.
154    */
155   static ConditionFunction GetFunction(Property::Type valueType);
156
157 private:
158
159   /**
160    * Checks if bool 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 EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
166
167   /**
168    * Checks if integer 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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
174
175   /**
176    * Checks if unsigned integer 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 EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
182
183   /**
184    * Checks if float is GreaterThan
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 EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
190
191   /**
192    * Checks if Vector2.Length() is GreaterThan
193    * @param[in] value The value being examined.
194    * @param[in] arg The supplied arguments for the condition.
195    * @return Condition result (true if condition met, false if not)
196    */
197   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
198
199   /**
200    * Checks if Vector3.Length() is GreaterThan
201    * @param[in] value The value being examined.
202    * @param[in] arg The supplied arguments for the condition.
203    * @return Condition result (true if condition met, false if not)
204    */
205   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
206
207   /**
208    * Checks if Vector4.Length() is GreaterThan
209    * @param[in] value The value being examined.
210    * @param[in] arg The supplied arguments for the condition.
211    * @return Condition result (true if condition met, false if not)
212    */
213   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
214
215   /**
216    * Default check for other types.
217    * @param[in] value The value being examined.
218    * @param[in] arg The supplied arguments for the condition.
219    * @return Condition result (true if condition met, false if not)
220    */
221   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
222
223 };
224
225 // Inside /////////////////////////////////////////////////////////////////////
226
227 /**
228  * Inside condition class,
229  * Checks if a Property is "Inside" the two arguments:
230  *
231  * bool       => false (0.0) or true (1.0) is inside arg0.
232  * float      => value is between arg0 and arg1.
233  * Vector2    => 2 dimensional length of vector is between arg0 and arg1.
234  * Vector3    => 3 dimensional length of vector is between arg0 and arg1.
235  * Vector4    => 4 dimensional length of vector is between arg0 and arg1.
236  * Default    => return false.
237  */
238 class Inside
239 {
240
241 public:
242
243   /**
244    * @return function pointer to the correct condition function, based on
245    * the type of value being examined.
246    */
247   static ConditionFunction GetFunction(Property::Type valueType);
248
249 private:
250
251   /**
252    * Checks if bool 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 EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
258
259   /**
260    * Checks if integer is Inside
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 EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
266
267   /**
268    * Checks if unsigned integer is Inside
269    * @param[in] value The value being examined.
270    * @param[in] arg The supplied arguments for the condition.
271    * @return Condition result (true if condition met, false if not)
272    */
273   static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
274
275   /**
276    * Checks if float is Inside
277    * @param[in] value The value being examined.
278    * @param[in] arg The supplied arguments for the condition.
279    * @return Condition result (true if condition met, false if not)
280    */
281   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
282
283   /**
284    * Checks if Vector2.Length() is Inside
285    * @param[in] value The value being examined.
286    * @param[in] arg The supplied arguments for the condition.
287    * @return Condition result (true if condition met, false if not)
288    */
289   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
290
291   /**
292    * Checks if Vector3.Length() is Inside
293    * @param[in] value The value being examined.
294    * @param[in] arg The supplied arguments for the condition.
295    * @return Condition result (true if condition met, false if not)
296    */
297   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
298
299   /**
300    * Checks if Vector4.Length() is Inside
301    * @param[in] value The value being examined.
302    * @param[in] arg The supplied arguments for the condition.
303    * @return Condition result (true if condition met, false if not)
304    */
305   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
306
307   /**
308    * Default check for other types.
309    * @param[in] value The value being examined.
310    * @param[in] arg The supplied arguments for the condition.
311    * @return Condition result (true if condition met, false if not)
312    */
313   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
314
315 };
316
317 // Outside ////////////////////////////////////////////////////////////////////
318
319 /**
320  * Outside condition class,
321  * Checks if a Property is "Outside" the two arguments:
322  *
323  * bool       => false (0.0) or true (1.0) is outside arg0.
324  * float      => value is outside arg0 and arg1.
325  * Vector2    => 2 dimensional length of vector is outside arg0 and arg1.
326  * Vector3    => 3 dimensional length of vector is outside arg0 and arg1.
327  * Vector4    => 4 dimensional length of vector is outside arg0 and arg1.
328  * Default    => return false.
329  */
330 class Outside
331 {
332
333 public:
334
335   /**
336    * @return function pointer to the correct condition function, based on
337    * the type of value being examined.
338    */
339   static ConditionFunction GetFunction(Property::Type valueType);
340
341 private:
342
343   /**
344    * Checks if bool is Outside
345    * @param[in] value The value being examined.
346    * @param[in] arg The supplied arguments for the condition.
347    * @return Condition result (true if condition met, false if not)
348    */
349   static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
350
351   /**
352    * Checks if integer is Outside
353    * @param[in] value The value being examined.
354    * @param[in] arg The supplied arguments for the condition.
355    * @return Condition result (true if condition met, false if not)
356    */
357   static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
358
359   /**
360    * Checks if unsigned integer is Outside
361    * @param[in] value The value being examined.
362    * @param[in] arg The supplied arguments for the condition.
363    * @return Condition result (true if condition met, false if not)
364    */
365   static bool EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
366
367   /**
368    * Checks if float is Outside
369    * @param[in] value The value being examined.
370    * @param[in] arg The supplied arguments for the condition.
371    * @return Condition result (true if condition met, false if not)
372    */
373   static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
374
375   /**
376    * Checks if Vector2.Length() is Outside
377    * @param[in] value The value being examined.
378    * @param[in] arg The supplied arguments for the condition.
379    * @return Condition result (true if condition met, false if not)
380    */
381   static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
382
383   /**
384    * Checks if Vector3.Length() is Outside
385    * @param[in] value The value being examined.
386    * @param[in] arg The supplied arguments for the condition.
387    * @return Condition result (true if condition met, false if not)
388    */
389   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
390
391   /**
392    * Checks if Vector4.Length() is Outside
393    * @param[in] value The value being examined.
394    * @param[in] arg The supplied arguments for the condition.
395    * @return Condition result (true if condition met, false if not)
396    */
397   static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
398
399   /**
400    * Default check for other types.
401    * @param[in] value The value being examined.
402    * @param[in] arg The supplied arguments for the condition.
403    * @return Condition result (true if condition met, false if not)
404    */
405   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
406
407 };
408
409 } // namespace SceneGraph
410
411 } // namespace Internal
412
413 } // namespace Dali
414
415 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_FUNCTIONS_H__