1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
5 * Copyright (c) 2018 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( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
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 != nullptr;
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 float Get( BufferIndex bufferIndex ) const
88 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr" );
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( nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr" );
98 mProperty->SetX( bufferIndex, value );
102 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
104 void Bake( BufferIndex bufferIndex, float value ) const
106 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr" );
107 mProperty->BakeX( bufferIndex, value );
113 PropertyComponentAccessorX() = delete;
114 PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
115 PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
119 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( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
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 != nullptr;
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 float Get( BufferIndex bufferIndex ) const
180 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr" );
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( nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr" );
190 mProperty->SetY( bufferIndex, value );
194 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
196 void Bake( BufferIndex bufferIndex, float value ) const
198 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr" );
199 mProperty->BakeY( bufferIndex, value );
205 PropertyComponentAccessorY() = delete;
206 PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
207 PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
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( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
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 != nullptr;
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 float Get( BufferIndex bufferIndex ) const
271 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr" );
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( nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr" );
281 mProperty->SetZ( bufferIndex, value );
285 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
287 void Bake( BufferIndex bufferIndex, float value ) const
289 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr" );
290 mProperty->BakeZ( bufferIndex, value );
296 PropertyComponentAccessorZ() = delete;
297 PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
298 PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
302 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
306 * A wrapper class for getting/setting a float component of another property.
307 * Animators use this instead of accessing properties directly.
309 template < typename PropertyType >
310 class PropertyComponentAccessorW
315 * Create a property component.
316 * @param [in] property The property which holds a float component.
318 PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
319 : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
324 * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
326 ~PropertyComponentAccessorW()
331 * Query whether the accessor is set.
332 * @return True if set.
336 return mProperty != nullptr;
340 * Reset the property accessor
341 * @post Calling any other PropertyComponentAccessorW is invalid.
349 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
353 return mProperty->IsClean();
357 * Read access to the property.
358 * @param [in] bufferIndex The current update buffer index.
360 float Get( BufferIndex bufferIndex ) const
362 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr" );
363 return mProperty->Get( bufferIndex ).w; // W Component only!
367 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
369 void Set( BufferIndex bufferIndex, float value ) const
371 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr" );
372 mProperty->SetW( bufferIndex, value );
376 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
378 void Bake( BufferIndex bufferIndex, float value ) const
380 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr" );
381 mProperty->BakeW( bufferIndex, value );
387 PropertyComponentAccessorW() = delete;
388 PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
389 PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
393 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
397 } // namespace Internal
401 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__