-#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H
+#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param [in] property The property to access.
*/
PropertyAccessor( SceneGraph::PropertyBase* property )
- : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+ : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
{
}
/**
* Non-virtual destructor; PropertyAccessor is not suitable as a base class.
*/
- ~PropertyAccessor()
- {
- }
+ ~PropertyAccessor() = default;
/**
* Query whether the accessor is set.
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
*/
const PropertyType& Get( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
return mProperty->Get( bufferIndex );
}
*/
void Set( BufferIndex bufferIndex, const PropertyType& value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
mProperty->Set( bufferIndex, value );
}
*/
void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
mProperty->Bake( bufferIndex, value );
}
private:
// Undefined
- PropertyAccessor(const PropertyAccessor& property);
-
- // Undefined
- PropertyAccessor& operator=(const PropertyAccessor& rhs);
+ PropertyAccessor() = delete;
+ PropertyAccessor(const PropertyAccessor& property) = delete;
+ PropertyAccessor& operator=(const PropertyAccessor& rhs) = delete;
private:
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
-};
-
+};
/**
- * A wrapper class for getting/setting a property.
+ * A wrapper class for getting/setting a transform manager property
* Animators use this instead of accessing properties directly.
*/
template <typename T>
* @param [in] property The property to access.
*/
TransformManagerPropertyAccessor( SceneGraph::PropertyBase* property )
- : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
+ : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
{
}
/**
* Non-virtual destructor; PropertyAccessor is not suitable as a base class.
*/
- ~TransformManagerPropertyAccessor()
- {
- }
+ ~TransformManagerPropertyAccessor() = default;
/**
* Query whether the accessor is set.
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
*/
const T& Get( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
return mProperty->Get( bufferIndex );
}
*/
void Set( BufferIndex bufferIndex, const T& value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
mProperty->Set( bufferIndex, value );
}
*/
void Bake( BufferIndex bufferIndex, const T& value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
mProperty->Bake( bufferIndex, value );
}
private:
// Undefined
- TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property);
-
- // Undefined
- TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs);
+ TransformManagerPropertyAccessor() = delete;
+ TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property) = delete;
+ TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs) = delete;
private:
SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
-};
+};
-template <typename T, unsigned int COMPONENT>
+/**
+ * A wrapper class for getting/setting a transform manager property component
+ * Animators use this instead of accessing properties directly.
+ */
+template <typename T, uint32_t COMPONENT>
class TransformManagerPropertyComponentAccessor
{
public:
* @param [in] property The property to access.
*/
TransformManagerPropertyComponentAccessor( SceneGraph::PropertyBase* property )
- : mProperty( dynamic_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) )
+ : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
{
}
/**
* Non-virtual destructor; PropertyAccessor is not suitable as a base class.
*/
- ~TransformManagerPropertyComponentAccessor()
- {
- }
+ ~TransformManagerPropertyComponentAccessor() = default;
/**
* Query whether the accessor is set.
*/
bool IsSet() const
{
- return mProperty != NULL;
+ return mProperty != nullptr;
}
/**
*/
void Reset()
{
- mProperty = NULL;
+ mProperty = nullptr;
}
/**
* @param [in] bufferIndex The current update buffer index.
* @return The value of the component of the property
*/
- const float& Get( BufferIndex bufferIndex ) const
+ float Get( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Get() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
return mProperty->GetFloatComponent( COMPONENT );
}
/**
* @copydoc AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, const float& value ) const
+ void Set( BufferIndex bufferIndex, float value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Set() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
mProperty->SetFloatComponent( value, COMPONENT );
}
/**
* @copydoc AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, const float& value ) const
+ void Bake( BufferIndex bufferIndex, float value ) const
{
- DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyAccessor::Bake() mProperty was NULL" );
+ DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
mProperty->BakeFloatComponent( value, COMPONENT );
}
private:
// Undefined
- TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property);
-
- // Undefined
- TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs);
+ TransformManagerPropertyComponentAccessor() = delete;
+ TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property) = delete;
+ TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs) = delete;
private:
SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
+
};
} // namespace Internal
} // namespace Dali
-#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H