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 connected to the scene graph.
59 * @param[in] owner A reference to the connected PropertyOwner
61 virtual void PropertyOwnerConnected( PropertyOwner& owner ) = 0;
64 * Called when the observable object is disconnected from the scene graph.
65 * @param[in] currentBufferIndex The buffer to reset.
66 * @param[in] owner A reference to the disconnected PropertyOwner
68 virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
71 * Called shortly before the observable object is destroyed.
73 * @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
74 * may not be called (i.e. when shutting down).
76 virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
80 * Create a property owner.
81 * @return A newly allocated object.
83 static PropertyOwner* New();
86 * Virtual destructor; this is intended as a base class.
88 virtual ~PropertyOwner();
92 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
93 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
94 * @param[in] observer The observer.
96 void AddObserver(Observer& observer);
100 * @param[in] observer The observer.
102 void RemoveObserver(Observer& observer);
105 * This method can be used to determine if there is an animation or
106 * constraint that is using this property owner.
107 * @return true if there are observers.
112 * Called just before destruction to disconnect all observers and remove constraints.
113 * This occurs when the object is in the process of being destroyed.
118 * Notify all observers that the object has been connected
119 * This occurs when the object is connected to the scene-graph during UpdateManager::Update().
121 void ConnectToSceneGraph();
124 * Notify all observers that the object has been disconnected and remove constraints.
125 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
126 * @param[in] currentBufferIndex The current update buffer.
128 void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
131 * Install a custom property.
132 * @post The PropertyOwner takes ownership of the property.
133 * @param[in] property A pointer to a newly allocated property.
135 void InstallCustomProperty(PropertyBase* property);
138 * Retrieve the custom properties owned by the object.
139 * @return A container of properties.
141 OwnedPropertyContainer& GetCustomProperties()
143 return mCustomProperties;
147 * Retrieve the custom properties owned by the object.
148 * @return A container of properties.
150 const OwnedPropertyContainer& GetCustomProperties() const
152 return mCustomProperties;
156 * Reset animatable properties to the corresponding base values.
157 * @param[in] currentBufferIndex The buffer to reset.
158 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
160 void ResetToBaseValues( BufferIndex updateBufferIndex );
165 * Apply a constraint.
166 * @param[in] constraint The constraint to apply.
168 void ApplyConstraint( ConstraintBase* constraint );
171 * Begin removal of constraints.
172 * @param[in] constraint The constraint to remove.
174 void RemoveConstraint( ConstraintBase* constraint );
177 * Retrieve the constraints that are currently applied.
178 * @return A container of constraints.
180 ConstraintOwnerContainer& GetConstraints();
185 * Protected constructor.
192 PropertyOwner(const PropertyOwner&);
195 PropertyOwner& operator=(const PropertyOwner& rhs);
198 * Called after ResetToBaseValues; derived classes should reset any default properties.
199 * @param[in] currentBufferIndex The buffer to reset.
201 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) {}
205 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
209 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
210 typedef ObserverContainer::Iterator ObserverIter;
211 typedef ObserverContainer::ConstIterator ConstObserverIter;
213 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
215 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
219 } // namespace SceneGraph
221 } // namespace Internal
225 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__