1 #ifndef __DALI_INTERNAL_PROPERTY_NOTIFICATION_H__
2 #define __DALI_INTERNAL_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/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;
59 typedef PropertyCondition::ArgumentContainer ArgumentContainer;
62 * RawArgumentContainer provides fast direct access to arguments for condition evaluation.
64 typedef Dali::Vector<float> RawArgumentContainer;
67 * Create a new PropertyNotification object.
68 * @param[in] target The target object to inspect
69 * @param[in] componentIndex Index to the component of a complex property such as a Vector
70 * @param[in] condition The condition for this notification.
71 * @return A smart-pointer to the newly allocated PropertyNotification.
73 static PropertyNotificationPtr New(Property& target,
75 const Dali::PropertyCondition& condition);
80 * @copydoc Dali::PropertyNotification::NotifySignal()
82 Dali::PropertyNotifySignalType& NotifySignal();
85 * Emit the Notify signal
87 void EmitSignalNotify();
90 * Enables PropertyNotification
95 * Disables PropertyNotification
100 * Sets the result from the property condition test for use by applications that connect to the notification signal
102 * @param[in] result The result of the property condition test
104 void SetNotifyResult(bool result);
107 * @copydoc Dali::PropertyNotification::GetCondition
109 const Dali::PropertyCondition& GetCondition() const;
112 * @copydoc Dali::PropertyNotification::GetTarget
114 Dali::Handle GetTarget() const;
117 * @copydoc Dali::PropertyNotification::GetTargetProperty
119 Property::Index GetTargetProperty() const;
122 * @copydoc Dali::PropertyNotification::SetNotifyMode
124 void SetNotifyMode( NotifyMode mode );
127 * @copydoc Dali::PropertyNotification::GetNotifyMode
129 NotifyMode GetNotifyMode();
132 * @copydoc Dali::PropertyNotification::GetNotifyResult
134 bool GetNotifyResult() const;
137 * Compare the passed sceneObject to the one created by this instance
138 * @param[in] sceneObject The SceneGraph::PropertyNotification pointer to compare
139 * @return true if sceneObject is the same as the one created by this instance
141 bool CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject );
146 * Construct a new PropertyNotification.
147 * @param[in] updateManager The UpdateManager associated with this PropertyNotification.
148 * @param[in] propertyNotificationManager The property notification manager object.
149 * @param[in] target The target property.
150 * @param[in] componentIndex Index to the component of a complex property such as a Vector
151 * @param[in] condition The condition for this notification.
153 PropertyNotification(SceneGraph::UpdateManager& updateManager,
154 PropertyNotificationManager& propertyNotificationManager,
157 const Dali::PropertyCondition& condition);
160 * Helper to create a scene-graph PropertyNotification
162 void CreateSceneObject();
165 * Helper to destroy a scene-graph PropertyNotification
167 void DestroySceneObject();
170 * A reference counted object may only be deleted by calling Unreference()
172 virtual ~PropertyNotification();
177 PropertyNotification(const PropertyNotification&);
180 PropertyNotification& operator=(const PropertyNotification& rhs);
184 SceneGraph::UpdateManager& mUpdateManager;
185 const SceneGraph::PropertyNotification* mPropertyNotification;
187 Dali::PropertyNotifySignalType mNotifySignal;
191 PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
192 Object* mObject; ///< Target object, not owned by PropertyNotification.
193 Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
194 Property::Type mPropertyType; ///< The type of property to evaluate
195 int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
196 Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
197 RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
198 NotifyMode mNotifyMode; ///< The current notification mode.
199 bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
202 } // namespace Internal
204 // Helpers for public-api forwarding methods
206 inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
208 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
210 BaseObject& handle = pub.GetBaseObject();
212 return static_cast<Internal::PropertyNotification&>(handle);
215 inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
217 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
219 const BaseObject& handle = pub.GetBaseObject();
221 return static_cast<const Internal::PropertyNotification&>(handle);
226 #endif // __DALI_INTERNAL_PROPERTY_NOTIFICATION_H__