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.
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/common/set-wrapper.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 * An update-thread object 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 * Create a property owner.
68 * @return A newly allocated object.
70 static PropertyOwner* New();
73 * Virtual destructor; this is intended as a base class.
75 virtual ~PropertyOwner();
79 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
80 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
81 * @param[in] observer The observer.
83 void AddObserver(Observer& observer);
87 * @param[in] observer The observer.
89 void RemoveObserver(Observer& observer);
92 * This method can be used to determine if there is an animation or
93 * constraint that is using this property owner.
94 * @return true if there are observers.
99 * Disconnect all observers and remove constraints.
100 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
102 void DisconnectFromSceneGraph();
105 * Install a custom property.
106 * @post The PropertyOwner takes ownership of the property.
107 * @param[in] property A pointer to a newly allocated property.
109 void InstallCustomProperty(PropertyBase* property);
112 * Retrieve the custom properties owned by the object.
113 * @return A container of properties.
115 OwnedPropertyContainer& GetCustomProperties()
117 return mCustomProperties;
121 * Retrieve the custom properties owned by the object.
122 * @return A container of properties.
124 const OwnedPropertyContainer& GetCustomProperties() const
126 return mCustomProperties;
130 * Reset animatable properties to the corresponding base values.
131 * @param[in] currentBufferIndex The buffer to reset.
132 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
134 void ResetToBaseValues( BufferIndex updateBufferIndex );
139 * Apply a constraint.
140 * @param[in] constraint The constraint to apply.
142 void ApplyConstraint( ConstraintBase* constraint );
145 * Begin removal of constraints.
146 * @param[in] constraint The constraint to remove.
148 void RemoveConstraint( ConstraintBase* constraint );
151 * Retrieve the constraints that are currently applied.
152 * @return A container of constraints.
154 ConstraintOwnerContainer& GetConstraints();
159 * Protected constructor.
166 PropertyOwner(const PropertyOwner&);
169 PropertyOwner& operator=(const PropertyOwner& rhs);
172 * Called after ResetToBaseValues; derived classes should reset any default properties.
173 * @param[in] currentBufferIndex The buffer to reset.
175 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) {}
179 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
183 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
184 typedef ObserverContainer::Iterator ObserverIter;
185 typedef ObserverContainer::ConstIterator ConstObserverIter;
187 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
189 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
193 } // namespace SceneGraph
195 } // namespace Internal
199 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__