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 Flora License, Version 1.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://floralicense.org/license/
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 std::set<PropertyOwner*> PropertyOwnerSet;
43 typedef PropertyOwnerSet::iterator PropertyOwnerIter;
45 typedef OwnerContainer< PropertyBase* > OwnedPropertyContainer;
46 typedef OwnedPropertyContainer::Iterator OwnedPropertyIter;
49 * Base for scene-graph objects which own properties.
50 * This allows observers to track the lifetime of the object & its properties.
61 * Called shortly before the observable object is destroyed.
63 virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
67 * Virtual destructor; this is intended as a base class.
69 virtual ~PropertyOwner();
73 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
74 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
75 * @param[in] observer The observer.
77 void AddObserver(Observer& observer);
81 * @param[in] observer The observer.
83 void RemoveObserver(Observer& observer);
86 * This method can be used to determine if there is an animation or
87 * constraint that is using this property owner.
88 * @return true if there are observers.
93 * Disconnect all observers and remove constraints.
94 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
96 void DisconnectFromSceneGraph();
99 * Install a custom property.
100 * @post The PropertyOwner takes ownership of the property.
101 * @param[in] property A pointer to a newly allocated property.
103 void InstallCustomProperty(PropertyBase* property);
106 * Retrieve the custom properties owned by the object.
107 * @return A container of properties.
109 OwnedPropertyContainer& GetCustomProperties()
111 return mCustomProperties;
115 * Retrieve the custom properties owned by the object.
116 * @return A container of properties.
118 const OwnedPropertyContainer& GetCustomProperties() const
120 return mCustomProperties;
124 * Reset animatable properties to the corresponding base values.
125 * @param[in] currentBufferIndex The buffer to reset.
126 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
128 void ResetToBaseValues( BufferIndex updateBufferIndex );
133 * Apply a constraint.
134 * @param[in] constraint The constraint to apply.
136 void ApplyConstraint( ConstraintBase* constraint );
139 * Begin removal of constraints.
140 * @param[in] constraint The constraint to remove.
142 void RemoveConstraint( ConstraintBase* constraint );
145 * Retrieve the constraints that are currently applied.
146 * @return A container of constraints.
148 ConstraintOwnerContainer& GetConstraints();
153 * Protected constructor.
160 PropertyOwner(const PropertyOwner&);
163 PropertyOwner& operator=(const PropertyOwner& rhs);
166 * Called after ResetToBaseValues; derived classes should reset any default properties.
167 * @param[in] currentBufferIndex The buffer to reset.
169 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) = 0;
173 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
177 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
178 typedef ObserverContainer::Iterator ObserverIter;
179 typedef ObserverContainer::ConstIterator ConstObserverIter;
181 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
183 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
187 } // namespace SceneGraph
189 } // namespace Internal
193 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__