1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_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 float component of another property.
32 * Animators use this instead of accessing properties directly.
34 template < typename PropertyType >
35 class PropertyComponentAccessorX
40 * Create a property component.
41 * @param [in] property The property which holds a float component.
43 PropertyComponentAccessorX( SceneGraph::PropertyBase* property )
44 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
49 * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class.
51 ~PropertyComponentAccessorX()
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 PropertyComponentAccessorX 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 float& Get( BufferIndex bufferIndex ) const
87 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Get() mProperty was NULL" );
88 return mProperty->Get( bufferIndex ).x; // X Component only!
92 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
94 void Set( BufferIndex bufferIndex, float value ) const
96 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Set() mProperty was NULL" );
97 mProperty->SetX( bufferIndex, value );
101 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
103 void Bake( BufferIndex bufferIndex, float value ) const
105 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Bake() mProperty was NULL" );
106 mProperty->BakeX( bufferIndex, value );
112 PropertyComponentAccessorX(const PropertyComponentAccessorX& property);
115 PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs);
119 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
123 * A wrapper class for getting/setting a float component of another property.
124 * Animators use this instead of accessing properties directly.
126 template < typename PropertyType >
127 class PropertyComponentAccessorY
132 * Create a property component.
133 * @param [in] property The property which holds a float component.
135 PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
136 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
141 * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
143 ~PropertyComponentAccessorY()
148 * Query whether the accessor is set.
149 * @return True if set.
153 return mProperty != NULL;
157 * Reset the property accessor
158 * @post Calling any other PropertyComponentAccessorY is invalid.
166 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
170 return mProperty->IsClean();
174 * Read access to the property.
175 * @param [in] bufferIndex The current update buffer index.
177 const float& Get( BufferIndex bufferIndex ) const
179 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Get() mProperty was NULL" );
180 return mProperty->Get( bufferIndex ).y; // Y Component only!
184 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
186 void Set( BufferIndex bufferIndex, float value ) const
188 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Set() mProperty was NULL" );
189 mProperty->SetY( bufferIndex, value );
193 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
195 void Bake( BufferIndex bufferIndex, float value ) const
197 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Bake() mProperty was NULL" );
198 mProperty->BakeY( bufferIndex, value );
204 PropertyComponentAccessorY(const PropertyComponentAccessorY& property);
207 PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs);
211 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
215 * A wrapper class for getting/setting a float component of another property.
216 * Animators use this instead of accessing properties directly.
218 template < typename PropertyType >
219 class PropertyComponentAccessorZ
224 * Create a property component.
225 * @param [in] property The property which holds a float component.
227 PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
228 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
233 * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
235 ~PropertyComponentAccessorZ()
240 * Query whether the accessor is set.
241 * @return True if set.
245 return mProperty != NULL;
249 * Reset the property accessor
250 * @post Calling any other PropertyComponentAccessorZ is invalid.
258 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
262 return mProperty->IsClean();
266 * Read access to the property.
267 * @param [in] bufferIndex The current update buffer index.
269 const float& Get( BufferIndex bufferIndex ) const
271 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Get() mProperty was NULL" );
272 return mProperty->Get( bufferIndex ).z; // Z Component only!
276 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
278 void Set( BufferIndex bufferIndex, float value ) const
280 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Set() mProperty was NULL" );
281 mProperty->SetZ( bufferIndex, value );
285 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
287 void Bake( BufferIndex bufferIndex, float value ) const
289 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was NULL" );
290 mProperty->BakeZ( bufferIndex, value );
296 PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property);
299 PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs);
303 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
307 * A wrapper class for getting/setting a float component of another property.
308 * Animators use this instead of accessing properties directly.
310 template < typename PropertyType >
311 class PropertyComponentAccessorW
316 * Create a property component.
317 * @param [in] property The property which holds a float component.
319 PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
320 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
325 * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
327 ~PropertyComponentAccessorW()
332 * Query whether the accessor is set.
333 * @return True if set.
337 return mProperty != NULL;
341 * Reset the property accessor
342 * @post Calling any other PropertyComponentAccessorW is invalid.
350 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
354 return mProperty->IsClean();
358 * Read access to the property.
359 * @param [in] bufferIndex The current update buffer index.
361 const float& Get( BufferIndex bufferIndex ) const
363 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Get() mProperty was NULL" );
364 return mProperty->Get( bufferIndex ).w; // W Component only!
368 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
370 void Set( BufferIndex bufferIndex, float value ) const
372 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Set() mProperty was NULL" );
373 mProperty->SetW( bufferIndex, value );
377 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
379 void Bake( BufferIndex bufferIndex, float value ) const
381 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Bake() mProperty was NULL" );
382 mProperty->BakeW( bufferIndex, value );
388 PropertyComponentAccessorW(const PropertyComponentAccessorW& property);
391 PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs);
395 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
398 } // namespace Internal
402 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__