Merge "Sync UTC harness" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / property-component-accessor.h
index e1e596b..95b6c2f 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
+#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
 #include <dali/internal/update/common/animatable-property.h>
+#include <dali/public-api/common/dali-common.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 /**
  * A wrapper class for getting/setting a float component of another property.
  * Animators use this instead of accessing properties directly.
  */
-template < typename PropertyType >
+template<typename PropertyType>
 class PropertyComponentAccessorX
 {
 public:
-
   /**
    * Create a property component.
    * @param [in] property The property which holds a float component.
    */
-  PropertyComponentAccessorX( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  PropertyComponentAccessorX(SceneGraph::PropertyBase* property)
+  : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
   {
   }
 
   /**
    * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class.
    */
-  ~PropertyComponentAccessorX()
-  {
-  }
+  ~PropertyComponentAccessorX() = default;
 
   /**
    * Query whether the accessor is set.
@@ -59,7 +54,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -68,7 +63,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -83,40 +78,37 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get(BufferIndex bufferIndex) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Get() mProperty was NULL" );
-    return mProperty->Get( bufferIndex ).x; // X Component only!
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr");
+    return mProperty->Get(bufferIndex).x; // X Component only!
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
    */
-  void Set( BufferIndex bufferIndex, float value ) const
+  void Set(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Set() mProperty was NULL" );
-    mProperty->SetX( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr");
+    mProperty->SetX(bufferIndex, value);
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
    */
-  void Bake( BufferIndex bufferIndex, float value ) const
+  void Bake(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorX::Bake() mProperty was NULL" );
-    mProperty->BakeX( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr");
+    mProperty->BakeX(bufferIndex, value);
   }
 
 private:
-
   // Undefined
-  PropertyComponentAccessorX(const PropertyComponentAccessorX& property);
-
-  // Undefined
-  PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs);
+  PropertyComponentAccessorX()                                           = delete;
+  PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
+  PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
 
 private:
-
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
 };
 
@@ -124,26 +116,23 @@ private:
  * A wrapper class for getting/setting a float component of another property.
  * Animators use this instead of accessing properties directly.
  */
-template < typename PropertyType >
+template<typename PropertyType>
 class PropertyComponentAccessorY
 {
 public:
-
   /**
    * Create a property component.
    * @param [in] property The property which holds a float component.
    */
-  PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  PropertyComponentAccessorY(SceneGraph::PropertyBase* property)
+  : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
   {
   }
 
   /**
    * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
    */
-  ~PropertyComponentAccessorY()
-  {
-  }
+  ~PropertyComponentAccessorY() = default;
 
   /**
    * Query whether the accessor is set.
@@ -151,7 +140,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -160,7 +149,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -175,40 +164,37 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get(BufferIndex bufferIndex) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Get() mProperty was NULL" );
-    return mProperty->Get( bufferIndex ).y; // Y Component only!
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr");
+    return mProperty->Get(bufferIndex).y; // Y Component only!
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
    */
-  void Set( BufferIndex bufferIndex, float value ) const
+  void Set(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Set() mProperty was NULL" );
-    mProperty->SetY( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr");
+    mProperty->SetY(bufferIndex, value);
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
    */
-  void Bake( BufferIndex bufferIndex, float value ) const
+  void Bake(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorY::Bake() mProperty was NULL" );
-    mProperty->BakeY( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr");
+    mProperty->BakeY(bufferIndex, value);
   }
 
 private:
-
-  // Undefined
-  PropertyComponentAccessorY(const PropertyComponentAccessorY& property);
-
   // Undefined
-  PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs);
+  PropertyComponentAccessorY()                                           = delete;
+  PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
+  PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
 
 private:
-
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
 };
 
@@ -216,26 +202,23 @@ private:
  * A wrapper class for getting/setting a float component of another property.
  * Animators use this instead of accessing properties directly.
  */
-template < typename PropertyType >
+template<typename PropertyType>
 class PropertyComponentAccessorZ
 {
 public:
-
   /**
    * Create a property component.
    * @param [in] property The property which holds a float component.
    */
-  PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  PropertyComponentAccessorZ(SceneGraph::PropertyBase* property)
+  : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
   {
   }
 
   /**
    * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
    */
-  ~PropertyComponentAccessorZ()
-  {
-  }
+  ~PropertyComponentAccessorZ() = default;
 
   /**
    * Query whether the accessor is set.
@@ -243,7 +226,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -252,7 +235,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -267,40 +250,37 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get(BufferIndex bufferIndex) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Get() mProperty was NULL" );
-    return mProperty->Get( bufferIndex ).z; // Z Component only!
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr");
+    return mProperty->Get(bufferIndex).z; // Z Component only!
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
    */
-  void Set( BufferIndex bufferIndex, float value ) const
+  void Set(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Set() mProperty was NULL" );
-    mProperty->SetZ( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr");
+    mProperty->SetZ(bufferIndex, value);
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
    */
-  void Bake( BufferIndex bufferIndex, float value ) const
+  void Bake(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was NULL" );
-    mProperty->BakeZ( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr");
+    mProperty->BakeZ(bufferIndex, value);
   }
 
 private:
-
-  // Undefined
-  PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property);
-
   // Undefined
-  PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs);
+  PropertyComponentAccessorZ()                                           = delete;
+  PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
+  PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
 
 private:
-
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
 };
 
@@ -308,26 +288,23 @@ private:
  * A wrapper class for getting/setting a float component of another property.
  * Animators use this instead of accessing properties directly.
  */
-template < typename PropertyType >
+template<typename PropertyType>
 class PropertyComponentAccessorW
 {
 public:
-
   /**
    * Create a property component.
    * @param [in] property The property which holds a float component.
    */
-  PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
-  : mProperty( dynamic_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) )
+  PropertyComponentAccessorW(SceneGraph::PropertyBase* property)
+  : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
   {
   }
 
   /**
    * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
    */
-  ~PropertyComponentAccessorW()
-  {
-  }
+  ~PropertyComponentAccessorW() = default;
 
   /**
    * Query whether the accessor is set.
@@ -335,7 +312,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -344,7 +321,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -359,40 +336,37 @@ public:
    * Read access to the property.
    * @param [in] bufferIndex The current update buffer index.
    */
-  const float& Get( BufferIndex bufferIndex ) const
+  float Get(BufferIndex bufferIndex) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Get() mProperty was NULL" );
-    return mProperty->Get( bufferIndex ).w; // W Component only!
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr");
+    return mProperty->Get(bufferIndex).w; // W Component only!
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
    */
-  void Set( BufferIndex bufferIndex, float value ) const
+  void Set(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Set() mProperty was NULL" );
-    mProperty->SetW( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr");
+    mProperty->SetW(bufferIndex, value);
   }
 
   /**
    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
    */
-  void Bake( BufferIndex bufferIndex, float value ) const
+  void Bake(BufferIndex bufferIndex, float value) const
   {
-    DALI_ASSERT_DEBUG( NULL != mProperty && "PropertyComponentAccessorW::Bake() mProperty was NULL" );
-    mProperty->BakeW( bufferIndex, value );
+    DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr");
+    mProperty->BakeW(bufferIndex, value);
   }
 
 private:
-
-  // Undefined
-  PropertyComponentAccessorW(const PropertyComponentAccessorW& property);
-
   // Undefined
-  PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs);
+  PropertyComponentAccessorW()                                           = delete;
+  PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
+  PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
 
 private:
-
   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
 };
 
@@ -400,4 +374,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H