1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
5 * Copyright (c) 2019 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/devel-api/common/owner-container.h>
24 #include <dali/internal/event/common/property-notification-impl.h>
25 #include <dali/internal/update/common/property-base.h>
34 class PropertyNotification;
39 class PropertyNotification;
41 using PropertyNotificationContainer = OwnerContainer<PropertyNotification*>;
42 using PropertyNotificationIter = PropertyNotificationContainer::Iterator;
43 using PropertyNotificationConstIter = PropertyNotificationContainer::ConstIterator;
44 using ConditionFunction = bool ( * )( const Dali::PropertyInput&, Dali::Internal::PropertyNotification::RawArgumentContainer& );
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
53 using NotifyMode = Dali::PropertyNotification::NotifyMode;
54 using ConditionType = Dali::Internal::PropertyNotification::ConditionType;
55 using RawArgumentContainer = Dali::Internal::PropertyNotification::RawArgumentContainer;
56 using GetPropertyFunction = const void* (*)( const SceneGraph::PropertyBase*, int );
59 * Construct a new PropertyNotification
60 * @param[in] object The event-object for a scene-graph object to inspect.
61 * @param[in] propertyIndex The index of a property provided by the object.
62 * @param[in] propertyType The type of property we're inspecting.
63 * @param[in] componentIndex Index to the component of a complex property such as a Vector
64 * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
65 * @param[in] arguments The arguments which accompany the condition.
66 * @param[in] notifyMode The notification mode setting
67 * @param[in] compare The flag of comparing the previous and current data.
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,
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] object The event-object 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(Object& object,
120 Property::Index propertyIndex,
121 Property::Type propertyType,
123 ConditionType condition,
124 RawArgumentContainer& arguments,
125 NotifyMode notifyMode,
131 * Checks if bool is LessThan
132 * @param[in] value The value being examined.
133 * @param[in] arg The supplied arguments for the condition.
134 * @return Condition result (true if condition met, false if not)
136 static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
139 PropertyNotification(const PropertyNotification&);
142 PropertyNotification& operator=(const PropertyNotification& rhs);
146 Object* mObject; ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
147 Property::Index mPropertyIndex; ///< The index of this property.
148 Property::Type mPropertyType; ///< The type of property this is.
149 const PropertyInputImpl* mProperty; ///< The scene graph property
150 int mComponentIndex; ///< Used for accessing float components of Vector3/4
151 ConditionType mConditionType; ///< The ConditionType
152 RawArgumentContainer mArguments; ///< The arguments.
153 bool mValid; ///< Whether this property notification is currently valid or not.
154 NotifyMode mNotifyMode; ///< Whether to notify on invalid and/or valid
155 ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
158 } // namespace SceneGraph
160 } // namespace Internal
164 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H