1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
5 * Copyright (c) 2019 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() = default;
55 * Query whether the accessor is set.
56 * @return True if set.
60 return mProperty != nullptr;
64 * Reset the property accessor
65 * @post Calling any other PropertyComponentAccessorX is invalid.
73 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
77 return mProperty->IsClean();
81 * Read access to the property.
82 * @param [in] bufferIndex The current update buffer index.
84 float Get( BufferIndex bufferIndex ) const
86 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr" );
87 return mProperty->Get( bufferIndex ).x; // X Component only!
91 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
93 void Set( BufferIndex bufferIndex, float value ) const
95 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr" );
96 mProperty->SetX( bufferIndex, value );
100 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
102 void Bake( BufferIndex bufferIndex, float value ) const
104 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr" );
105 mProperty->BakeX( bufferIndex, value );
111 PropertyComponentAccessorX() = delete;
112 PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
113 PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
117 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
122 * A wrapper class for getting/setting a float component of another property.
123 * Animators use this instead of accessing properties directly.
125 template < typename PropertyType >
126 class PropertyComponentAccessorY
131 * Create a property component.
132 * @param [in] property The property which holds a float component.
134 PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
135 : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
140 * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
142 ~PropertyComponentAccessorY() = default;
145 * Query whether the accessor is set.
146 * @return True if set.
150 return mProperty != nullptr;
154 * Reset the property accessor
155 * @post Calling any other PropertyComponentAccessorY is invalid.
163 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
167 return mProperty->IsClean();
171 * Read access to the property.
172 * @param [in] bufferIndex The current update buffer index.
174 float Get( BufferIndex bufferIndex ) const
176 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr" );
177 return mProperty->Get( bufferIndex ).y; // Y Component only!
181 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
183 void Set( BufferIndex bufferIndex, float value ) const
185 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr" );
186 mProperty->SetY( bufferIndex, value );
190 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
192 void Bake( BufferIndex bufferIndex, float value ) const
194 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr" );
195 mProperty->BakeY( bufferIndex, value );
201 PropertyComponentAccessorY() = delete;
202 PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
203 PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
207 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
211 * A wrapper class for getting/setting a float component of another property.
212 * Animators use this instead of accessing properties directly.
214 template < typename PropertyType >
215 class PropertyComponentAccessorZ
220 * Create a property component.
221 * @param [in] property The property which holds a float component.
223 PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
224 : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
229 * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
231 ~PropertyComponentAccessorZ() = default;
234 * Query whether the accessor is set.
235 * @return True if set.
239 return mProperty != nullptr;
243 * Reset the property accessor
244 * @post Calling any other PropertyComponentAccessorZ is invalid.
252 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
256 return mProperty->IsClean();
260 * Read access to the property.
261 * @param [in] bufferIndex The current update buffer index.
263 float Get( BufferIndex bufferIndex ) const
265 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr" );
266 return mProperty->Get( bufferIndex ).z; // Z Component only!
270 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
272 void Set( BufferIndex bufferIndex, float value ) const
274 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr" );
275 mProperty->SetZ( bufferIndex, value );
279 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
281 void Bake( BufferIndex bufferIndex, float value ) const
283 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr" );
284 mProperty->BakeZ( bufferIndex, value );
290 PropertyComponentAccessorZ() = delete;
291 PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
292 PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
296 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
300 * A wrapper class for getting/setting a float component of another property.
301 * Animators use this instead of accessing properties directly.
303 template < typename PropertyType >
304 class PropertyComponentAccessorW
309 * Create a property component.
310 * @param [in] property The property which holds a float component.
312 PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
313 : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
318 * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
320 ~PropertyComponentAccessorW() = default;
323 * Query whether the accessor is set.
324 * @return True if set.
328 return mProperty != nullptr;
332 * Reset the property accessor
333 * @post Calling any other PropertyComponentAccessorW is invalid.
341 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
345 return mProperty->IsClean();
349 * Read access to the property.
350 * @param [in] bufferIndex The current update buffer index.
352 float Get( BufferIndex bufferIndex ) const
354 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr" );
355 return mProperty->Get( bufferIndex ).w; // W Component only!
359 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
361 void Set( BufferIndex bufferIndex, float value ) const
363 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr" );
364 mProperty->SetW( bufferIndex, value );
368 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
370 void Bake( BufferIndex bufferIndex, float value ) const
372 DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr" );
373 mProperty->BakeW( bufferIndex, value );
379 PropertyComponentAccessorW() = delete;
380 PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
381 PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
385 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
389 } // namespace Internal
393 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H