1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
5 * Copyright (c) 2021 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/internal/update/common/animatable-property.h>
23 #include <dali/public-api/common/dali-common.h>
30 * A wrapper class for getting/setting a float component of another property.
31 * Animators use this instead of accessing properties directly.
33 template<typename PropertyType>
34 class PropertyComponentAccessorX
38 * Create a property component.
39 * @param [in] property The property which holds a float component.
41 PropertyComponentAccessorX(SceneGraph::PropertyBase* property)
42 : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
47 * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class.
49 ~PropertyComponentAccessorX() = default;
52 * Query whether the accessor is set.
53 * @return True if set.
57 return mProperty != nullptr;
61 * Reset the property accessor
62 * @post Calling any other PropertyComponentAccessorX is invalid.
70 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
74 return mProperty->IsClean();
78 * Read access to the property.
79 * @param [in] bufferIndex The current update buffer index.
81 float Get(BufferIndex bufferIndex) const
83 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr");
84 return mProperty->Get(bufferIndex).x; // X Component only!
88 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
90 void Set(BufferIndex bufferIndex, float value) const
92 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr");
93 mProperty->SetX(bufferIndex, value);
97 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
99 void Bake(BufferIndex bufferIndex, float value) const
101 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr");
102 mProperty->BakeX(bufferIndex, value);
107 PropertyComponentAccessorX() = delete;
108 PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
109 PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
112 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
116 * A wrapper class for getting/setting a float component of another property.
117 * Animators use this instead of accessing properties directly.
119 template<typename PropertyType>
120 class PropertyComponentAccessorY
124 * Create a property component.
125 * @param [in] property The property which holds a float component.
127 PropertyComponentAccessorY(SceneGraph::PropertyBase* property)
128 : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
133 * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
135 ~PropertyComponentAccessorY() = default;
138 * Query whether the accessor is set.
139 * @return True if set.
143 return mProperty != nullptr;
147 * Reset the property accessor
148 * @post Calling any other PropertyComponentAccessorY is invalid.
156 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
160 return mProperty->IsClean();
164 * Read access to the property.
165 * @param [in] bufferIndex The current update buffer index.
167 float Get(BufferIndex bufferIndex) const
169 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr");
170 return mProperty->Get(bufferIndex).y; // Y Component only!
174 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
176 void Set(BufferIndex bufferIndex, float value) const
178 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr");
179 mProperty->SetY(bufferIndex, value);
183 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
185 void Bake(BufferIndex bufferIndex, float value) const
187 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr");
188 mProperty->BakeY(bufferIndex, value);
193 PropertyComponentAccessorY() = delete;
194 PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
195 PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
198 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
202 * A wrapper class for getting/setting a float component of another property.
203 * Animators use this instead of accessing properties directly.
205 template<typename PropertyType>
206 class PropertyComponentAccessorZ
210 * Create a property component.
211 * @param [in] property The property which holds a float component.
213 PropertyComponentAccessorZ(SceneGraph::PropertyBase* property)
214 : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
219 * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
221 ~PropertyComponentAccessorZ() = default;
224 * Query whether the accessor is set.
225 * @return True if set.
229 return mProperty != nullptr;
233 * Reset the property accessor
234 * @post Calling any other PropertyComponentAccessorZ is invalid.
242 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
246 return mProperty->IsClean();
250 * Read access to the property.
251 * @param [in] bufferIndex The current update buffer index.
253 float Get(BufferIndex bufferIndex) const
255 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr");
256 return mProperty->Get(bufferIndex).z; // Z Component only!
260 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
262 void Set(BufferIndex bufferIndex, float value) const
264 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr");
265 mProperty->SetZ(bufferIndex, value);
269 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
271 void Bake(BufferIndex bufferIndex, float value) const
273 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr");
274 mProperty->BakeZ(bufferIndex, value);
279 PropertyComponentAccessorZ() = delete;
280 PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
281 PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
284 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
288 * A wrapper class for getting/setting a float component of another property.
289 * Animators use this instead of accessing properties directly.
291 template<typename PropertyType>
292 class PropertyComponentAccessorW
296 * Create a property component.
297 * @param [in] property The property which holds a float component.
299 PropertyComponentAccessorW(SceneGraph::PropertyBase* property)
300 : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
305 * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
307 ~PropertyComponentAccessorW() = default;
310 * Query whether the accessor is set.
311 * @return True if set.
315 return mProperty != nullptr;
319 * Reset the property accessor
320 * @post Calling any other PropertyComponentAccessorW is invalid.
328 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
332 return mProperty->IsClean();
336 * Read access to the property.
337 * @param [in] bufferIndex The current update buffer index.
339 float Get(BufferIndex bufferIndex) const
341 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr");
342 return mProperty->Get(bufferIndex).w; // W Component only!
346 * @copydoc SceneGraph::AnimatableProperty<float>::Set()
348 void Set(BufferIndex bufferIndex, float value) const
350 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr");
351 mProperty->SetW(bufferIndex, value);
355 * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
357 void Bake(BufferIndex bufferIndex, float value) const
359 DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr");
360 mProperty->BakeW(bufferIndex, value);
365 PropertyComponentAccessorW() = delete;
366 PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
367 PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
370 SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
373 } // namespace Internal
377 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H