#define DALI_INTERNAL_PROPERTY_METADATA_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <utility>
// INTERNAL INCLUDES
+#include <dali/internal/common/const-string.h>
#include <dali/public-api/common/constants.h>
-#include <dali/public-api/object/property.h>
#include <dali/public-api/object/property-value.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class PropertyBase;
class PropertyMetadata
{
public:
-
/**
* @brief Virtual Destructor.
*/
- virtual ~PropertyMetadata()
- {
- }
+ virtual ~PropertyMetadata() = default;
/**
* @brief Returns whether the property is animatable (i.e. if its a scene graph property).
* @return True if animatable, false otherwise
*/
- bool IsAnimatable( void ) const
+ bool IsAnimatable(void) const
{
- return NULL != mSceneGraphProperty;
+ return nullptr != mSceneGraphProperty;
}
/**
* @brief Whether the property can be written to.
* @return True if the property can be written to, false otherwise
*/
- bool IsWritable( void ) const
+ bool IsWritable(void) const
{
return mWritable;
}
*/
const SceneGraph::PropertyBase* GetSceneGraphProperty() const
{
- DALI_ASSERT_DEBUG( mSceneGraphProperty && "Accessing uninitialized SceneGraph property" );
+ DALI_ASSERT_DEBUG(mSceneGraphProperty && "Accessing uninitialized SceneGraph property");
return mSceneGraphProperty;
}
* Set the cached value of the property.
* @param[in] value The propertyValue to set.
*/
- void SetPropertyValue( const Property::Value& propertyValue );
+ void SetPropertyValue(const Property::Value& propertyValue);
/**
* Get the cached value of a the property.
* Modifies the stored value by the relativeValue.
* @param[in] relativeValue The value to change by.
*/
- void AdjustPropertyValueBy( const Property::Value& relativeValue );
+ void AdjustPropertyValueBy(const Property::Value& relativeValue);
protected:
-
/**
* @brief Constructor to create Metadata for a property.
* @param[in] propertyValue The value of the property (this is used by the event thread)
* @param[in] sceneGraphProperty A pointer to the scene-graph owned property
* @param[in] writable Whether the property is writable
*/
- PropertyMetadata( const Property::Value& propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty,
- bool writable )
- : value( mStoredValue ),
- componentIndex( Property::INVALID_COMPONENT_INDEX ),
- mStoredValue( propertyValue ),
- mSceneGraphProperty( sceneGraphProperty ),
- mWritable( writable )
+ PropertyMetadata(Property::Value propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty,
+ bool writable)
+ : value(mStoredValue),
+ componentIndex(Property::INVALID_COMPONENT_INDEX),
+ mStoredValue(std::move(propertyValue)),
+ mSceneGraphProperty(sceneGraphProperty),
+ mWritable(writable)
{
}
* @param[in] baseValueRef A reference to the metadata of the base animatable property
* @param[in] propertyComponentIndex The component index of the property
*/
- PropertyMetadata( const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int32_t propertyComponentIndex )
- : value( baseValueRef ),
- componentIndex( propertyComponentIndex ),
+ PropertyMetadata(const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int32_t propertyComponentIndex)
+ : value(baseValueRef),
+ componentIndex(propertyComponentIndex),
mStoredValue(),
- mSceneGraphProperty( sceneGraphProperty ),
- mWritable( writable )
+ mSceneGraphProperty(sceneGraphProperty),
+ mWritable(writable)
{
}
private:
-
// Not implemented
- PropertyMetadata( const PropertyMetadata& );
- PropertyMetadata& operator=( const PropertyMetadata& );
+ PropertyMetadata(const PropertyMetadata&);
+ PropertyMetadata& operator=(const PropertyMetadata&);
public: // Data
-
/**
* @brief The value of this property used to read/write by the event thread.
*
int32_t componentIndex;
private:
-
- Property::Value mStoredValue; ///< The cached property value used to read/write by the event thread
- const SceneGraph::PropertyBase* mSceneGraphProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread
- bool mWritable:1; ///< Whether the property is writable
+ Property::Value mStoredValue; ///< The cached property value used to read/write by the event thread
+ const SceneGraph::PropertyBase* mSceneGraphProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread
+ bool mWritable : 1; ///< Whether the property is writable
};
/**
class AnimatablePropertyMetadata : public PropertyMetadata
{
public:
-
/**
* @brief Constructs metadata for a registered animatable property.
* @param[in] propertyIndex The index of the animatable property
*
* @note The base animatable property MUST be created before the component animatable property.
*/
- AnimatablePropertyMetadata( Property::Index propertyIndex,
- const Property::Value& propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( propertyValue, sceneGraphProperty, true ),
- index( propertyIndex )
+ AnimatablePropertyMetadata(Property::Index propertyIndex,
+ Property::Value propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(std::move(propertyValue), sceneGraphProperty, true),
+ index(propertyIndex)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
*
* @note The base animatable property MUST be created before the component animatable property.
*/
- AnimatablePropertyMetadata( Property::Index propertyIndex,
- int propertyComponentIndex,
- Property::Value& baseValueRef,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( sceneGraphProperty, true, baseValueRef, propertyComponentIndex ),
- index( propertyIndex )
+ AnimatablePropertyMetadata(Property::Index propertyIndex,
+ int propertyComponentIndex,
+ Property::Value& baseValueRef,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(sceneGraphProperty, true, baseValueRef, propertyComponentIndex),
+ index(propertyIndex)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
* @brief Destructor.
*/
- virtual ~AnimatablePropertyMetadata()
- {
- }
+ ~AnimatablePropertyMetadata() override = default;
private:
-
// Not implemented
AnimatablePropertyMetadata();
- AnimatablePropertyMetadata( const AnimatablePropertyMetadata& );
- AnimatablePropertyMetadata& operator=( const AnimatablePropertyMetadata& );
+ AnimatablePropertyMetadata(const AnimatablePropertyMetadata&);
+ AnimatablePropertyMetadata& operator=(const AnimatablePropertyMetadata&);
-public: // Data
-
- Property::Index index; ///< The index of the property.
+public: // Data
+ Property::Index index; ///< The index of the property.
};
class CustomPropertyMetadata : public PropertyMetadata
{
public:
-
/**
* Constructs Metadata for scene-graph-based custom properties, i.e. animatable custom properties.
* @param[in] propertyName The name of the custom property
*
* @note A valid sceneGraphProperty is mandatory otherwise this will debug assert.
*/
- CustomPropertyMetadata( const std::string& propertyName,
- Property::Index propertyKey,
- const Property::Value& propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( propertyValue, sceneGraphProperty, true ),
- name( propertyName ),
- key( propertyKey ),
- childPropertyIndex( Property::INVALID_INDEX )
+ CustomPropertyMetadata(ConstString propertyName,
+ Property::Index propertyKey,
+ Property::Value propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(std::move(propertyValue), sceneGraphProperty, true),
+ name(propertyName),
+ key(propertyKey),
+ childPropertyIndex(Property::INVALID_INDEX)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
*
* @note The access mode MUST NOT be animatable otherwise this will debug assert.
*/
- CustomPropertyMetadata( const std::string& propertyName,
- const Property::Value& propertyValue,
- Property::AccessMode accessMode )
- : PropertyMetadata( propertyValue, NULL, ( accessMode != Property::READ_ONLY ) ),
- name( propertyName ),
- key( Property::INVALID_KEY ),
- childPropertyIndex( Property::INVALID_INDEX )
+ CustomPropertyMetadata(ConstString propertyName,
+ Property::Value propertyValue,
+ Property::AccessMode accessMode)
+ : PropertyMetadata(std::move(propertyValue), nullptr, (accessMode != Property::READ_ONLY)),
+ name(propertyName),
+ key(Property::INVALID_KEY),
+ childPropertyIndex(Property::INVALID_INDEX)
{
- DALI_ASSERT_DEBUG( accessMode != Property::ANIMATABLE && "Event side only properties should not be animatable" );
+ DALI_ASSERT_DEBUG(accessMode != Property::ANIMATABLE && "Event side only properties should not be animatable");
}
/**
* @brief Destructor.
*/
- virtual ~CustomPropertyMetadata()
- {
- }
+ ~CustomPropertyMetadata() override = default;
private:
-
// Not implemented
CustomPropertyMetadata();
- CustomPropertyMetadata( const CustomPropertyMetadata& );
- CustomPropertyMetadata& operator=( const CustomPropertyMetadata& );
-
-public: // Data
+ CustomPropertyMetadata(const CustomPropertyMetadata&);
+ CustomPropertyMetadata& operator=(const CustomPropertyMetadata&);
- std::string name; ///< The name of the property.
- Property::Index key; ///< The key of the property.
- Property::Index childPropertyIndex; ///< The index as a child property.
+public: // Data
+ ConstString name; ///< The name of the property.
+ Property::Index key; ///< The key of the property.
+ Property::Index childPropertyIndex; ///< The index as a child property.
};
} // namespace Internal