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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/property-notification.h>
23 #include <dali/internal/event/common/property-notification-impl.h>
24 #include <dali/internal/update/common/property-base.h>
25 #include <dali/internal/common/owner-container.h>
34 class PropertyNotification;
39 class PropertyNotification;
41 typedef OwnerContainer< PropertyNotification* > PropertyNotificationContainer;
42 typedef PropertyNotificationContainer::Iterator PropertyNotificationIter;
43 typedef PropertyNotificationContainer::ConstIterator PropertyNotificationConstIter;
44 typedef bool(*ConditionFunction)(const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& args);
47 * PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
48 * managers "update" phase. When a condition has been met the application receives a notification signal.
50 class PropertyNotification
54 typedef Dali::PropertyNotification::NotifyMode NotifyMode;
55 typedef Dali::Internal::PropertyNotification::ConditionType ConditionType;
56 typedef Dali::Internal::PropertyNotification::RawArgumentContainer RawArgumentContainer;
57 typedef const void *(*GetPropertyFunction)( const SceneGraph::PropertyBase*, int );
60 * Construct a new PropertyNotification
61 * @param[in] object The event-object for a scene-graph object to inspect.
62 * @param[in] propertyIndex The index of a property provided by the object.
63 * @param[in] propertyType The type of property we're inspecting.
64 * @param[in] componentIndex Index to the component of a complex property such as a Vector
65 * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
66 * @param[in] arguments The arguments which accompany the condition.
67 * @param[in] notifyMode The notification mode setting
68 * @return A new PropertyNotification object.
70 static PropertyNotification* New(Object& object,
71 Property::Index propertyIndex,
72 Property::Type propertyType,
74 ConditionType condition,
75 RawArgumentContainer& arguments,
76 NotifyMode notifyMode);
81 virtual ~PropertyNotification();
84 * Sets Notify Mode, whether to notify if the condition is true
85 * and if the condition is false.
87 * @param[in] notifyMode The notification mode setting
89 void SetNotifyMode( NotifyMode notifyMode );
92 * Check this property notification condition,
93 * and if true then dispatch notification.
94 * @param[in] bufferIndex The current update buffer index.
95 * @return Whether the validity of this notification has changed.
97 bool Check( BufferIndex bufferIndex );
100 * Returns the validity of the last condition check
102 * @return the validity
104 bool GetValidity() const;
109 * Construct the PropertyNotification
110 * @param[in] object The event-object for a scene-graph object to inspect.
111 * @param[in] propertyIndex The index of a property provided by the object.
112 * @param[in] propertyType The type of property we're inspecting.
113 * @param[in] componentIndex Index to the component of a complex property such as a Vector
114 * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
115 * @param[in] arguments The arguments which accompany the condition.
116 * @param[in] notifyMode The notification mode setting
118 PropertyNotification(Object& object,
119 Property::Index propertyIndex,
120 Property::Type propertyType,
122 ConditionType condition,
123 RawArgumentContainer& arguments,
124 NotifyMode notifyMode);
129 * Checks if bool is LessThan
130 * @param[in] value The value being examined.
131 * @param[in] arg The supplied arguments for the condition.
132 * @return Condition result (true if condition met, false if not)
134 static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
137 PropertyNotification(const PropertyNotification&);
140 PropertyNotification& operator=(const PropertyNotification& rhs);
144 Object* mObject; ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
145 Property::Index mPropertyIndex; ///< The index of this property.
146 Property::Type mPropertyType; ///< The type of property this is.
147 const PropertyInputImpl* mProperty; ///< The scene graph property
148 int mComponentIndex; ///< Used for accessing float components of Vector3/4
149 ConditionType mConditionType; ///< The ConditionType
150 RawArgumentContainer mArguments; ///< The arguments.
151 bool mValid; ///< Whether this property notification is currently valid or not.
152 NotifyMode mNotifyMode; ///< Whether to notify on invalid and/or valid
153 ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
156 } // namespace SceneGraph
158 } // namespace Internal
162 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H__