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 shortly before the observable object is destroyed.
64 virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
68 * Create a property owner.
69 * @return A newly allocated object.
71 static PropertyOwner* New();
74 * Virtual destructor; this is intended as a base class.
76 virtual ~PropertyOwner();
80 * The observer is responsible for calling RemoveObserver(*this) during its own destruction.
81 * Connecting an actor-side object as an observer is not allowed, due to thread-safety issues.
82 * @param[in] observer The observer.
84 void AddObserver(Observer& observer);
88 * @param[in] observer The observer.
90 void RemoveObserver(Observer& observer);
93 * This method can be used to determine if there is an animation or
94 * constraint that is using this property owner.
95 * @return true if there are observers.
100 * Disconnect all observers and remove constraints.
101 * This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
103 void DisconnectFromSceneGraph();
106 * Install a custom property.
107 * @post The PropertyOwner takes ownership of the property.
108 * @param[in] property A pointer to a newly allocated property.
110 void InstallCustomProperty(PropertyBase* property);
113 * Retrieve the custom properties owned by the object.
114 * @return A container of properties.
116 OwnedPropertyContainer& GetCustomProperties()
118 return mCustomProperties;
122 * Retrieve the custom properties owned by the object.
123 * @return A container of properties.
125 const OwnedPropertyContainer& GetCustomProperties() const
127 return mCustomProperties;
131 * Reset animatable properties to the corresponding base values.
132 * @param[in] currentBufferIndex The buffer to reset.
133 * @post The ResetDefaultProperties method is called, during which derived classes can reset default properties.
135 void ResetToBaseValues( BufferIndex updateBufferIndex );
140 * Apply a constraint.
141 * @param[in] constraint The constraint to apply.
143 void ApplyConstraint( ConstraintBase* constraint );
146 * Begin removal of constraints.
147 * @param[in] constraint The constraint to remove.
149 void RemoveConstraint( ConstraintBase* constraint );
152 * Retrieve the constraints that are currently applied.
153 * @return A container of constraints.
155 ConstraintOwnerContainer& GetConstraints();
160 * Protected constructor.
167 PropertyOwner(const PropertyOwner&);
170 PropertyOwner& operator=(const PropertyOwner& rhs);
173 * Called after ResetToBaseValues; derived classes should reset any default properties.
174 * @param[in] currentBufferIndex The buffer to reset.
176 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ) {}
180 OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
184 typedef Dali::Vector<PropertyOwner::Observer*> ObserverContainer;
185 typedef ObserverContainer::Iterator ObserverIter;
186 typedef ObserverContainer::ConstIterator ConstObserverIter;
188 ObserverContainer mObservers; ///< Container of observer raw-pointers (not owned)
190 ConstraintOwnerContainer mConstraints; ///< Container of owned constraints
194 } // namespace SceneGraph
196 } // namespace Internal
200 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H__