Do not register processor when registering singleton
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-metadata.h
index b845eaa..9ef14dc 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_PROPERTY_METADATA_H__
-#define __DALI_INTERNAL_PROPERTY_METADATA_H__
+#ifndef DALI_INTERNAL_PROPERTY_METADATA_H
+#define DALI_INTERNAL_PROPERTY_METADATA_H
 
 /*
- * Copyright (c) 2017 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;
@@ -57,28 +56,25 @@ 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;
   }
@@ -91,7 +87,7 @@ public:
    */
   const SceneGraph::PropertyBase* GetSceneGraphProperty() const
   {
-    DALI_ASSERT_DEBUG( mSceneGraphProperty && "Accessing uninitialized SceneGraph property" );
+    DALI_ASSERT_DEBUG(mSceneGraphProperty && "Accessing uninitialized SceneGraph property");
     return mSceneGraphProperty;
   }
 
@@ -108,7 +104,7 @@ public:
    * 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.
@@ -120,24 +116,23 @@ public:
    * 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)
   {
   }
 
@@ -148,42 +143,39 @@ protected:
    * @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, int 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.
    *
-   * If a component index, then refers to the value in the PropertyMetatdata of the base property
+   * If this PropertyMetadata is for property component, then refers to the value in the PropertyMetadata of the base property
    * to ensure the components are kept in sync with the overall value on the event thread.
-   * Otherwise, this just refers to the storedValue.
+   * Otherwise, this refers to mStoredValue.
    */
   Property::Value& value;
 
   /**
    * @brief The index of the property component.
    */
-  int componentIndex;
+  int32_t componentIndex;
 
 private:
-
-  Property::Value mStoredValue;                         ///< The stored 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
 };
 
 /**
@@ -192,7 +184,6 @@ private:
 class AnimatablePropertyMetadata : public PropertyMetadata
 {
 public:
-
   /**
    * @brief Constructs metadata for a registered animatable property.
    * @param[in] propertyIndex           The index of the animatable property
@@ -202,13 +193,13 @@ public:
    *
    * @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");
   }
 
   /**
@@ -220,39 +211,34 @@ public:
    *
    * @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
@@ -262,16 +248,16 @@ public:
    *
    * @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");
   }
 
   /**
@@ -282,40 +268,36 @@ public:
    *
    * @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
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_PROPERTY_METADATA_H__
+#endif // DALI_INTERNAL_PROPERTY_METADATA_H