1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_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.
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/internal/update/common/animatable-property.h>
24 #include <dali/internal/update/manager/transform-manager-property.h>
33 * A wrapper class for getting/setting a property.
34 * Animators use this instead of accessing properties directly.
36 template < typename PropertyType >
37 class PropertyAccessor
42 * Create a property component.
43 * @param [in] property The property to access.
45 PropertyAccessor( SceneGraph::PropertyBase* property )
46 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
51 * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
58 * Query whether the accessor is set.
59 * @return True if set.
63 return mProperty != NULL;
67 * Reset the property accessor
68 * @post Calling any other PropertyAccessor is invalid.
76 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
80 return mProperty->IsClean();
84 * Read access to the property.
85 * @param [in] bufferIndex The current update buffer index.
87 const PropertyType& Get( BufferIndex bufferIndex ) const
89 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
90 return mProperty->Get( bufferIndex );
94 * @copydoc AnimatableProperty<float>::Set()
96 void Set( BufferIndex bufferIndex, const PropertyType& value ) const
98 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
99 mProperty->Set( bufferIndex, value );
103 * @copydoc AnimatableProperty<float>::Bake()
105 void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
107 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
108 mProperty->Bake( bufferIndex, value );
114 PropertyAccessor(const PropertyAccessor& property);
117 PropertyAccessor& operator=(const PropertyAccessor& rhs);
121 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
127 * A wrapper class for getting/setting a property.
128 * Animators use this instead of accessing properties directly.
130 template <typename T>
131 class TransformManagerPropertyAccessor
136 * Create a property component.
137 * @param [in] property The property to access.
139 TransformManagerPropertyAccessor( SceneGraph::PropertyBase* property )
140 : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
145 * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
147 ~TransformManagerPropertyAccessor()
152 * Query whether the accessor is set.
153 * @return True if set.
157 return mProperty != NULL;
161 * Reset the property accessor
162 * @post Calling any other PropertyAccessor is invalid.
170 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
174 return mProperty->IsClean();
178 * Read access to the property.
179 * @param [in] bufferIndex The current update buffer index.
180 * @return The value of the property
182 const T& Get( BufferIndex bufferIndex ) const
184 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
185 return mProperty->Get( bufferIndex );
189 * @copydoc AnimatableProperty<float>::Set()
191 void Set( BufferIndex bufferIndex, const T& value ) const
193 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
194 mProperty->Set( bufferIndex, value );
198 * @copydoc AnimatableProperty<float>::Bake()
200 void Bake( BufferIndex bufferIndex, const T& value ) const
202 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
203 mProperty->Bake( bufferIndex, value );
209 TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property);
212 TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs);
216 SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
220 template <typename T, unsigned int COMPONENT>
221 class TransformManagerPropertyComponentAccessor
226 * Create a property component.
227 * @param [in] property The property to access.
229 TransformManagerPropertyComponentAccessor( SceneGraph::PropertyBase* property )
230 : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
235 * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
237 ~TransformManagerPropertyComponentAccessor()
242 * Query whether the accessor is set.
243 * @return True if set.
247 return mProperty != NULL;
251 * Reset the property accessor
252 * @post Calling any other PropertyAccessor is invalid.
260 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
264 return mProperty->IsClean();
268 * Read access to the property.
269 * @param [in] bufferIndex The current update buffer index.
270 * @return The value of the component of the property
272 const float& Get( BufferIndex bufferIndex ) const
274 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
275 return mProperty->GetFloatComponent( COMPONENT );
279 * @copydoc AnimatableProperty<float>::Set()
281 void Set( BufferIndex bufferIndex, const float& value ) const
283 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
284 mProperty->SetFloatComponent( value, COMPONENT );
288 * @copydoc AnimatableProperty<float>::Bake()
290 void Bake( BufferIndex bufferIndex, const float& value ) const
292 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
293 mProperty->BakeFloatComponent( value, COMPONENT );
299 TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property);
302 TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs);
306 SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
309 } // namespace Internal
313 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__