1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_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.
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/common/owner-container.h>
27 #include <dali/internal/update/common/property-base.h>
28 #include <dali/internal/update/common/scene-graph-buffers.h>
29 #include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
42 typedef OwnerContainer< PropertyBase* > OwnedPropertyContainer;
43 typedef OwnedPropertyContainer::Iterator OwnedPropertyIter;
46 * An update-thread object which own properties.
47 * This allows observers to track the lifetime of the object & its properties.
58 * Called when the observable object is disconnected from the scene graph.
59 * @param[in] currentBufferIndex The buffer to reset.
60 * @post The observer is automatically disconnected
61 * (observer will not receive the PropertyOwnerDestroyed callback after this)
63 virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
66 * Called shortly before the observable object is destroyed.
68 * @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
69 * may not be called (i.e. when shutting down).
71 virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
75 * Create a property owner.
76 * @return A newly allocated object.
78 static PropertyOwner* New();
81 * Virtual destructor; this is intended as a base class.
83 virtual ~PropertyOwner();
87 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
88 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
89 * @param[in] observer The observer.
91 void AddObserver(Observer& observer);
95 * @param[in] observer The observer.
97 void RemoveObserver(Observer& observer);
100 * This method can be used to determine if there is an animation or
101 * constraint that is using this property owner.
102 * @return true if there are observers.
107 * Called just before destruction to disconnect all observers and remove constraints.
108 * This occurs when the object is in the process of being destroyed.
113 * Disconnect all observers and remove constraints.
114 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
115 * @param[in] currentBufferIndex The current update buffer.
117 void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
120 * Install a custom property.
121 * @post The PropertyOwner takes ownership of the property.
122 * @param[in] property A pointer to a newly allocated property.
124 void InstallCustomProperty(PropertyBase* property);
127 * Retrieve the custom properties owned by the object.
128 * @return A container of properties.
130 OwnedPropertyContainer& GetCustomProperties()
132 return mCustomProperties;
136 * Retrieve the custom properties owned by the object.
137 * @return A container of properties.
139 const OwnedPropertyContainer& GetCustomProperties() const
141 return mCustomProperties;
145 * Reset animatable properties to the corresponding base values.
146 * @param[in] currentBufferIndex The buffer to reset.
147 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
149 void ResetToBaseValues( BufferIndex updateBufferIndex );
154 * Apply a constraint.
155 * @param[in] constraint The constraint to apply.
157 void ApplyConstraint( ConstraintBase* constraint );
160 * Begin removal of constraints.
161 * @param[in] constraint The constraint to remove.
163 void RemoveConstraint( ConstraintBase* constraint );
166 * Retrieve the constraints that are currently applied.
167 * @return A container of constraints.
169 ConstraintOwnerContainer& GetConstraints();
174 * Protected constructor.
181 PropertyOwner(const PropertyOwner&);
184 PropertyOwner& operator=(const PropertyOwner& rhs);
187 * Called after ResetToBaseValues; derived classes should reset any default properties.
188 * @param[in] currentBufferIndex The buffer to reset.
190 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) {}
194 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
198 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
199 typedef ObserverContainer::Iterator ObserverIter;
200 typedef ObserverContainer::ConstIterator ConstObserverIter;
202 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
204 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
208 } // namespace SceneGraph
210 } // namespace Internal
214 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__