Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-property-notification.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/object/property-notification.h>
22 #include <dali/internal/event/common/property-notification-impl.h>
23 #include <dali/internal/update/common/property-base.h>
24 #include <dali/internal/common/owner-container.h>
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/update/common/double-buffered.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 class ProxyObject;
35 class PropertyNotification;
36
37 namespace SceneGraph
38 {
39
40 class PropertyNotification;
41
42 typedef OwnerContainer< PropertyNotification* > PropertyNotificationContainer;
43 typedef PropertyNotificationContainer::Iterator PropertyNotificationIter;
44 typedef PropertyNotificationContainer::ConstIterator PropertyNotificationConstIter;
45 typedef bool(*ConditionFunction)(const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& args);
46
47 /**
48  * PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
49  * managers "update" phase. When a condition has been met the application receives a notification signal.
50  */
51 class PropertyNotification
52 {
53 public:
54
55   typedef Dali::PropertyNotification::NotifyMode NotifyMode;
56   typedef Dali::Internal::PropertyNotification::ConditionType ConditionType;
57   typedef Dali::Internal::PropertyNotification::RawArgumentContainer RawArgumentContainer;
58   typedef const void *(*GetPropertyFunction)( const SceneGraph::PropertyBase*, int );
59
60   /**
61    * Construct a new PropertyNotification
62    * @param[in] proxy The proxy for a scene-graph object to inspect.
63    * @param[in] propertyIndex The index of a property provided by the object.
64    * @param[in] propertyType The type of property we're inspecting.
65    * @param[in] componentIndex Index to the component of a complex property such as a Vector
66    * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
67    * @param[in] arguments The arguments which accompany the condition.
68    * @param[in] notifyMode The notification mode setting
69    * @return A new PropertyNotification object.
70    */
71   static PropertyNotification* New(ProxyObject& proxy,
72                                    Property::Index propertyIndex,
73                                    Property::Type propertyType,
74                                    int componentIndex,
75                                    ConditionType condition,
76                                    RawArgumentContainer& arguments,
77                                    NotifyMode notifyMode);
78
79   /**
80    * Virtual destructor
81    */
82   virtual ~PropertyNotification();
83
84   /**
85    * Sets Notify Mode, whether to notify if the condition is true
86    * and if the condition is false.
87    *
88    * @param[in] notifyMode The notification mode setting
89    */
90   void SetNotifyMode( NotifyMode notifyMode );
91
92   /**
93    * Check this property notification condition,
94    * and if true then dispatch notification.
95    * @param[in] bufferIndex The current update buffer index.
96    * @return Whether the validity of this notification has changed.
97    */
98   bool Check( BufferIndex bufferIndex );
99
100   /**
101    * Returns the validity of the last condition check
102    *
103    * @return the validity
104    */
105   bool GetValidity() const;
106
107 protected:
108
109   /**
110    * Construct the PropertyNotification
111    * @param[in] proxy The proxy for a scene-graph object to inspect.
112    * @param[in] propertyIndex The index of a property provided by the object.
113    * @param[in] propertyType The type of property we're inspecting.
114    * @param[in] componentIndex Index to the component of a complex property such as a Vector
115    * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
116    * @param[in] arguments The arguments which accompany the condition.
117    * @param[in] notifyMode The notification mode setting
118    */
119   PropertyNotification(ProxyObject& proxy,
120                        Property::Index propertyIndex,
121                        Property::Type propertyType,
122                        int componentIndex,
123                        ConditionType condition,
124                        RawArgumentContainer& arguments,
125                        NotifyMode notifyMode);
126
127 private:
128
129   /**
130    * Checks if bool is LessThan
131    * @param[in] value The value being examined.
132    * @param[in] arg The supplied arguments for the condition.
133    * @return Condition result (true if condition met, false if not)
134    */
135   static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
136
137   // Undefined
138   PropertyNotification(const PropertyNotification&);
139
140   // Undefined
141   PropertyNotification& operator=(const PropertyNotification& rhs);
142
143 protected:
144
145   ProxyObject* mProxy;                          ///< Not owned by the property notification. Valid until ProxyDestroyed() is called.
146   Property::Index mPropertyIndex;               ///< The index of this property.
147   Property::Type mPropertyType;                 ///< The type of property this is.
148   const PropertyInputImpl* mProperty;           ///< The scene graph property
149   int mComponentIndex;                          ///< Used for accessing float components of Vector3/4
150   ConditionType mConditionType;                 ///< The ConditionType
151   RawArgumentContainer mArguments;              ///< The arguments.
152   bool mValid;                                  ///< Whether this property notification is currently valid or not.
153   char mNotifyValidity[2];                      ///< Whether to notify on invalid and/or valid
154   ConditionFunction mConditionFunction;         ///< The Condition Function pointer to be evaluated.
155 };
156
157 // Messages for PropertyNotification
158
159 } // namespace SceneGraph
160
161 } // namespace Internal
162
163 } // namespace Dali
164
165 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__