1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
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>
35 class PropertyNotification;
40 class PropertyNotification;
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);
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.
51 class PropertyNotification
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 );
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.
71 static PropertyNotification* New(ProxyObject& proxy,
72 Property::Index propertyIndex,
73 Property::Type propertyType,
75 ConditionType condition,
76 RawArgumentContainer& arguments,
77 NotifyMode notifyMode);
82 virtual ~PropertyNotification();
85 * Sets Notify Mode, whether to notify if the condition is true
86 * and if the condition is false.
88 * @param[in] notifyMode The notification mode setting
90 void SetNotifyMode( NotifyMode notifyMode );
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.
98 bool Check( BufferIndex bufferIndex );
101 * Returns the validity of the last condition check
103 * @return the validity
105 bool GetValidity() const;
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
119 PropertyNotification(ProxyObject& proxy,
120 Property::Index propertyIndex,
121 Property::Type propertyType,
123 ConditionType condition,
124 RawArgumentContainer& arguments,
125 NotifyMode notifyMode);
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)
135 static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
138 PropertyNotification(const PropertyNotification&);
141 PropertyNotification& operator=(const PropertyNotification& rhs);
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.
157 // Messages for PropertyNotification
159 } // namespace SceneGraph
161 } // namespace Internal
165 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__