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 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 float component of another property.
33 * Animators use this instead of accessing properties directly.
35 template < typename PropertyType >
36 class PropertyComponentAccessorX
41 * Create a property component.
42 * @param [in] property The property which holds a float component.
44 PropertyComponentAccessorX( SceneGraph::PropertyBase* property )
45 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
50 * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class.
52 ~PropertyComponentAccessorX()
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 PropertyComponentAccessorX 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 float& Get( BufferIndex bufferIndex ) const
88 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Get() mProperty was NULL" );
89 return mProperty->Get( bufferIndex ).x; // X Component only!
93 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
95 void Set( BufferIndex bufferIndex, float value ) const
97 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Set() mProperty was NULL" );
98 mProperty->SetX( bufferIndex, value );
102 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
104 void Bake( BufferIndex bufferIndex, float value ) const
106 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Bake() mProperty was NULL" );
107 mProperty->BakeX( bufferIndex, value );
113 PropertyComponentAccessorX(const PropertyComponentAccessorX& property);
116 PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs);
120 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
124 * A wrapper class for getting/setting a float component of another property.
125 * Animators use this instead of accessing properties directly.
127 template < typename PropertyType >
128 class PropertyComponentAccessorY
133 * Create a property component.
134 * @param [in] property The property which holds a float component.
136 PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
137 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
142 * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
144 ~PropertyComponentAccessorY()
149 * Query whether the accessor is set.
150 * @return True if set.
154 return mProperty != NULL;
158 * Reset the property accessor
159 * @post Calling any other PropertyComponentAccessorY is invalid.
167 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
171 return mProperty->IsClean();
175 * Read access to the property.
176 * @param [in] bufferIndex The current update buffer index.
178 const float& Get( BufferIndex bufferIndex ) const
180 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Get() mProperty was NULL" );
181 return mProperty->Get( bufferIndex ).y; // Y Component only!
185 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
187 void Set( BufferIndex bufferIndex, float value ) const
189 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Set() mProperty was NULL" );
190 mProperty->SetY( bufferIndex, value );
194 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
196 void Bake( BufferIndex bufferIndex, float value ) const
198 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Bake() mProperty was NULL" );
199 mProperty->BakeY( bufferIndex, value );
205 PropertyComponentAccessorY(const PropertyComponentAccessorY& property);
208 PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs);
212 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
216 * A wrapper class for getting/setting a float component of another property.
217 * Animators use this instead of accessing properties directly.
219 template < typename PropertyType >
220 class PropertyComponentAccessorZ
225 * Create a property component.
226 * @param [in] property The property which holds a float component.
228 PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
229 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
234 * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
236 ~PropertyComponentAccessorZ()
241 * Query whether the accessor is set.
242 * @return True if set.
246 return mProperty != NULL;
250 * Reset the property accessor
251 * @post Calling any other PropertyComponentAccessorZ is invalid.
259 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
263 return mProperty->IsClean();
267 * Read access to the property.
268 * @param [in] bufferIndex The current update buffer index.
270 const float& Get( BufferIndex bufferIndex ) const
272 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Get() mProperty was NULL" );
273 return mProperty->Get( bufferIndex ).z; // Z Component only!
277 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
279 void Set( BufferIndex bufferIndex, float value ) const
281 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Set() mProperty was NULL" );
282 mProperty->SetZ( bufferIndex, value );
286 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
288 void Bake( BufferIndex bufferIndex, float value ) const
290 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was NULL" );
291 mProperty->BakeZ( bufferIndex, value );
297 PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property);
300 PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs);
304 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
308 * A wrapper class for getting/setting a float component of another property.
309 * Animators use this instead of accessing properties directly.
311 template < typename PropertyType >
312 class PropertyComponentAccessorW
317 * Create a property component.
318 * @param [in] property The property which holds a float component.
320 PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
321 : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
326 * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
328 ~PropertyComponentAccessorW()
333 * Query whether the accessor is set.
334 * @return True if set.
338 return mProperty != NULL;
342 * Reset the property accessor
343 * @post Calling any other PropertyComponentAccessorW is invalid.
351 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
355 return mProperty->IsClean();
359 * Read access to the property.
360 * @param [in] bufferIndex The current update buffer index.
362 const float& Get( BufferIndex bufferIndex ) const
364 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Get() mProperty was NULL" );
365 return mProperty->Get( bufferIndex ).w; // W Component only!
369 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
371 void Set( BufferIndex bufferIndex, float value ) const
373 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Set() mProperty was NULL" );
374 mProperty->SetW( bufferIndex, value );
378 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
380 void Bake( BufferIndex bufferIndex, float value ) const
382 DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Bake() mProperty was NULL" );
383 mProperty->BakeW( bufferIndex, value );
389 PropertyComponentAccessorW(const PropertyComponentAccessorW& property);
392 PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs);
396 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
399 } // namespace Internal
403 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__