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>
32 * A wrapper class for getting/setting a property.
33 * Animators use this instead of accessing properties directly.
35 template < typename PropertyType >
36 class PropertyAccessor
41 * Create a property component.
42 * @param [in] property The property to access.
44 PropertyAccessor( SceneGraph::PropertyBase* property )
45 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
50 * Non-virtual destructor; PropertyAccessor is not suitable as a base class.
57 * Query whether the accessor is set.
58 * @return True if set.
62 return mProperty != NULL;
66 * Reset the property accessor
67 * @post Calling any other PropertyAccessor is invalid.
75 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
79 return mProperty->IsClean();
83 * Read access to the property.
84 * @param [in] bufferIndex The current update buffer index.
86 const PropertyType& Get( BufferIndex bufferIndex ) const
88 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
89 return mProperty->Get( bufferIndex );
93 * @copydoc AnimatableProperty<float>::Set()
95 void Set( BufferIndex bufferIndex, const PropertyType& value ) const
97 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
98 mProperty->Set( bufferIndex, value );
102 * @copydoc AnimatableProperty<float>::Bake()
104 void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
106 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
107 mProperty->Bake( bufferIndex, value );
113 PropertyAccessor(const PropertyAccessor& property);
116 PropertyAccessor& operator=(const PropertyAccessor& rhs);
120 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
123 } // namespace Internal
127 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__