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/public-api/common/set-wrapper.h>
26 #include <dali/internal/common/message.h>
27 #include <dali/internal/common/owner-container.h>
28 #include <dali/internal/update/common/property-base.h>
29 #include <dali/internal/update/common/scene-graph-buffers.h>
30 #include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
43 typedef std::set<PropertyOwner*> PropertyOwnerSet;
44 typedef PropertyOwnerSet::iterator PropertyOwnerIter;
46 typedef OwnerContainer< PropertyBase* > OwnedPropertyContainer;
47 typedef OwnedPropertyContainer::Iterator OwnedPropertyIter;
50 * An update-thread object which own properties.
51 * This allows observers to track the lifetime of the object & its properties.
62 * Called when the observable object is disconnected from the scene graph.
63 * @param[in] currentBufferIndex The buffer to reset.
64 * @post The observer is automatically disconnected
65 * (observer will not receive the PropertyOwnerDestroyed callback after this)
67 virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
70 * Called shortly before the observable object is destroyed.
72 * @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
73 * may not be called (i.e. when shutting down).
75 virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
79 * Create a property owner.
80 * @return A newly allocated object.
82 static PropertyOwner* New();
85 * Virtual destructor; this is intended as a base class.
87 virtual ~PropertyOwner();
91 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
92 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
93 * @param[in] observer The observer.
95 void AddObserver(Observer& observer);
99 * @param[in] observer The observer.
101 void RemoveObserver(Observer& observer);
104 * This method can be used to determine if there is an animation or
105 * constraint that is using this property owner.
106 * @return true if there are observers.
111 * Called just before destruction to disconnect all observers and remove constraints.
112 * This occurs when the object is in the process of being destroyed.
117 * Disconnect all observers and remove constraints.
118 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
119 * @param[in] currentBufferIndex The current update buffer.
121 void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
124 * Install a custom property.
125 * @post The PropertyOwner takes ownership of the property.
126 * @param[in] property A pointer to a newly allocated property.
128 void InstallCustomProperty(PropertyBase* property);
131 * Retrieve the custom properties owned by the object.
132 * @return A container of properties.
134 OwnedPropertyContainer& GetCustomProperties()
136 return mCustomProperties;
140 * Retrieve the custom properties owned by the object.
141 * @return A container of properties.
143 const OwnedPropertyContainer& GetCustomProperties() const
145 return mCustomProperties;
149 * Reset animatable properties to the corresponding base values.
150 * @param[in] currentBufferIndex The buffer to reset.
151 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
153 void ResetToBaseValues( BufferIndex updateBufferIndex );
158 * Apply a constraint.
159 * @param[in] constraint The constraint to apply.
161 void ApplyConstraint( ConstraintBase* constraint );
164 * Begin removal of constraints.
165 * @param[in] constraint The constraint to remove.
167 void RemoveConstraint( ConstraintBase* constraint );
170 * Retrieve the constraints that are currently applied.
171 * @return A container of constraints.
173 ConstraintOwnerContainer& GetConstraints();
178 * Protected constructor.
185 PropertyOwner(const PropertyOwner&);
188 PropertyOwner& operator=(const PropertyOwner& rhs);
191 * Called after ResetToBaseValues; derived classes should reset any default properties.
192 * @param[in] currentBufferIndex The buffer to reset.
194 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) {}
198 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
202 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
203 typedef ObserverContainer::Iterator ObserverIter;
204 typedef ObserverContainer::ConstIterator ConstObserverIter;
206 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
208 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
212 } // namespace SceneGraph
214 } // namespace Internal
218 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__