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 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.
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/internal/update/common/animatable-property.h>
31 * A wrapper class for getting/setting a property.
32 * Animators use this instead of accessing properties directly.
34 template < typename PropertyType >
35 class PropertyAccessor
40 * Create a property component.
41 * @param [in] property The property to access.
43 PropertyAccessor( SceneGraph::PropertyBase* property )
44 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
49 * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
56 * Query whether the accessor is set.
57 * @return True if set.
61 return mProperty != NULL;
65 * Reset the property accessor
66 * @post Calling any other PropertyAccessor is invalid.
74 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
78 return mProperty->IsClean();
82 * Read access to the property.
83 * @param [in] bufferIndex The current update buffer index.
85 const PropertyType& Get( BufferIndex bufferIndex ) const
87 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
88 return mProperty->Get( bufferIndex );
92 * @copydoc AnimatableProperty<float>::Set()
94 void Set( BufferIndex bufferIndex, const PropertyType& value ) const
96 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
97 mProperty->Set( bufferIndex, value );
101 * @copydoc AnimatableProperty<float>::Bake()
103 void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
105 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
106 mProperty->Bake( bufferIndex, value );
112 PropertyAccessor(const PropertyAccessor& property);
115 PropertyAccessor& operator=(const PropertyAccessor& rhs);
119 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
122 } // namespace Internal
126 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__