1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
5 * Copyright (c) 2021 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/devel-api/common/owner-container.h>
23 #include <dali/internal/event/common/property-notification-impl.h>
24 #include <dali/internal/update/common/property-base.h>
25 #include <dali/public-api/object/property-notification.h>
32 class PropertyNotification;
36 class PropertyNotification;
38 using PropertyNotificationContainer = OwnerContainer<PropertyNotification*>;
39 using PropertyNotificationIter = PropertyNotificationContainer::Iterator;
40 using PropertyNotificationConstIter = PropertyNotificationContainer::ConstIterator;
41 using ConditionFunction = bool (*)(const Dali::PropertyInput&, Dali::Internal::PropertyNotification::RawArgumentContainer&);
44 * PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
45 * managers "update" phase. When a condition has been met the application receives a notification signal.
47 class PropertyNotification
50 using NotifyMode = Dali::PropertyNotification::NotifyMode;
51 using ConditionType = Dali::Internal::PropertyNotification::ConditionType;
52 using RawArgumentContainer = Dali::Internal::PropertyNotification::RawArgumentContainer;
53 using GetPropertyFunction = const void* (*)(const SceneGraph::PropertyBase*, int);
56 * Construct a new PropertyNotification
57 * @param[in] object The event-object for a scene-graph object to inspect.
58 * @param[in] propertyIndex The index of a property provided by the object.
59 * @param[in] propertyType The type of property we're inspecting.
60 * @param[in] componentIndex Index to the component of a complex property such as a Vector
61 * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
62 * @param[in] arguments The arguments which accompany the condition.
63 * @param[in] notifyMode The notification mode setting
64 * @param[in] compare The flag of comparing the previous and current data.
65 * @return A new PropertyNotification object.
67 static PropertyNotification* New(Object& object,
68 Property::Index propertyIndex,
69 Property::Type propertyType,
71 ConditionType condition,
72 RawArgumentContainer& arguments,
73 NotifyMode notifyMode,
79 virtual ~PropertyNotification();
82 * Sets Notify Mode, whether to notify if the condition is true
83 * and if the condition is false.
85 * @param[in] notifyMode The notification mode setting
87 void SetNotifyMode(NotifyMode notifyMode);
90 * Check this property notification condition,
91 * and if true then dispatch notification.
92 * @param[in] bufferIndex The current update buffer index.
93 * @return Whether the validity of this notification has changed.
95 bool Check(BufferIndex bufferIndex);
98 * Returns the validity of the last condition check
100 * @return the validity
102 bool GetValidity() const;
106 * Construct the PropertyNotification
107 * @param[in] object The event-object for a scene-graph object to inspect.
108 * @param[in] propertyIndex The index of a property provided by the object.
109 * @param[in] propertyType The type of property we're inspecting.
110 * @param[in] componentIndex Index to the component of a complex property such as a Vector
111 * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
112 * @param[in] arguments The arguments which accompany the condition.
113 * @param[in] notifyMode The notification mode setting
115 PropertyNotification(Object& object,
116 Property::Index propertyIndex,
117 Property::Type propertyType,
119 ConditionType condition,
120 RawArgumentContainer& arguments,
121 NotifyMode notifyMode,
126 * Checks if bool is LessThan
127 * @param[in] value The value being examined.
128 * @param[in] arg The supplied arguments for the condition.
129 * @return Condition result (true if condition met, false if not)
131 static bool EvalFalse(const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg);
134 PropertyNotification(const PropertyNotification&);
137 PropertyNotification& operator=(const PropertyNotification& rhs);
140 Object* mObject; ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
141 Property::Index mPropertyIndex; ///< The index of this property.
142 Property::Type mPropertyType; ///< The type of property this is.
143 const PropertyInputImpl* mProperty; ///< The scene graph property
144 int mComponentIndex; ///< Used for accessing float components of Vector3/4
145 ConditionType mConditionType; ///< The ConditionType
146 RawArgumentContainer mArguments; ///< The arguments.
147 bool mValid; ///< Whether this property notification is currently valid or not.
148 NotifyMode mNotifyMode; ///< Whether to notify on invalid and/or valid
149 ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
152 } // namespace SceneGraph
154 } // namespace Internal
158 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H