1 #ifndef __DALI_INTERNAL_PROPERTY_NOTIFICATION_H__
2 #define __DALI_INTERNAL_PROPERTY_NOTIFICATION_H__
5 * Copyright (c) 2015 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/common/dali-vector.h>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/internal/event/common/property-conditions-impl.h>
30 class PropertyCondition;
37 class PropertyNotification;
42 class PropertyNotification;
44 class PropertyNotificationManager;
46 typedef IntrusivePtr<PropertyNotification> PropertyNotificationPtr;
49 * PropertyNotification is a proxy for a SceneGraph::PropertyNotification object.
50 * The UpdateManager owns the PropertyNotification object, but the lifetime of the PropertyNotification is
51 * indirectly controlled by the PropertyNotification.
53 class PropertyNotification : public BaseObject
57 typedef Dali::PropertyNotification::NotifyMode NotifyMode;
58 typedef PropertyCondition::Type ConditionType;
61 * RawArgumentContainer provides fast direct access to arguments for condition evaluation.
63 typedef Dali::Vector<float> RawArgumentContainer;
66 * Create a new PropertyNotification object.
67 * @param[in] target The target object to inspect
68 * @param[in] componentIndex Index to the component of a complex property such as a Vector
69 * @param[in] condition The condition for this notification.
70 * @return A smart-pointer to the newly allocated PropertyNotification.
72 static PropertyNotificationPtr New(Property& target,
74 const Dali::PropertyCondition& condition);
79 * @copydoc Dali::PropertyNotification::NotifySignal()
81 Dali::PropertyNotifySignalType& NotifySignal();
84 * Emit the Notify signal
86 void EmitSignalNotify();
89 * Enables PropertyNotification
94 * Disables PropertyNotification
99 * Sets the result from the property condition test for use by applications that connect to the notification signal
101 * @param[in] result The result of the property condition test
103 void SetNotifyResult(bool result);
106 * @copydoc Dali::PropertyNotification::GetCondition
108 const Dali::PropertyCondition& GetCondition() const;
111 * @copydoc Dali::PropertyNotification::GetTarget
113 Dali::Handle GetTarget() const;
116 * @copydoc Dali::PropertyNotification::GetTargetProperty
118 Property::Index GetTargetProperty() const;
121 * @copydoc Dali::PropertyNotification::SetNotifyMode
123 void SetNotifyMode( NotifyMode mode );
126 * @copydoc Dali::PropertyNotification::GetNotifyMode
128 NotifyMode GetNotifyMode();
131 * @copydoc Dali::PropertyNotification::GetNotifyResult
133 bool GetNotifyResult() const;
136 * Compare the passed sceneObject to the one created by this instance
137 * @param[in] sceneObject The SceneGraph::PropertyNotification pointer to compare
138 * @return true if sceneObject is the same as the one created by this instance
140 bool CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject );
145 * Construct a new PropertyNotification.
146 * @param[in] updateManager The UpdateManager associated with this PropertyNotification.
147 * @param[in] propertyNotificationManager The property notification manager object.
148 * @param[in] target The target property.
149 * @param[in] componentIndex Index to the component of a complex property such as a Vector
150 * @param[in] condition The condition for this notification.
152 PropertyNotification(SceneGraph::UpdateManager& updateManager,
153 PropertyNotificationManager& propertyNotificationManager,
156 const Dali::PropertyCondition& condition);
159 * Helper to create a scene-graph PropertyNotification
161 void CreateSceneObject();
164 * Helper to destroy a scene-graph PropertyNotification
166 void DestroySceneObject();
169 * A reference counted object may only be deleted by calling Unreference()
171 virtual ~PropertyNotification();
176 PropertyNotification(const PropertyNotification&);
179 PropertyNotification& operator=(const PropertyNotification& rhs);
183 SceneGraph::UpdateManager& mUpdateManager;
184 const SceneGraph::PropertyNotification* mPropertyNotification;
186 Dali::PropertyNotifySignalType mNotifySignal;
190 PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
191 Object* mObject; ///< Target object, not owned by PropertyNotification.
192 Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
193 Property::Type mPropertyType; ///< The type of property to evaluate
194 int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
195 Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
196 RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
197 NotifyMode mNotifyMode; ///< The current notification mode.
198 bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
201 } // namespace Internal
203 // Helpers for public-api forwarding methods
205 inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
207 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
209 BaseObject& handle = pub.GetBaseObject();
211 return static_cast<Internal::PropertyNotification&>(handle);
214 inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
216 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
218 const BaseObject& handle = pub.GetBaseObject();
220 return static_cast<const Internal::PropertyNotification&>(handle);
225 #endif // __DALI_INTERNAL_PROPERTY_NOTIFICATION_H__