Merge "use modern construct '= default' for special functions." into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / property-accessor.h
index f745112..813dacf 100644 (file)
@@ -1,8 +1,8 @@
-#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) 2018 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.
@@ -43,16 +43,14 @@ public:
    * @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.
@@ -60,7 +58,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -69,7 +67,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -86,7 +84,7 @@ public:
    */
   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 );
   }
 
@@ -95,7 +93,7 @@ public:
    */
   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 );
   }
 
@@ -104,27 +102,25 @@ public:
    */
   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>
@@ -137,16 +133,14 @@ public:
    * @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.
@@ -154,7 +148,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -163,7 +157,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -181,7 +175,7 @@ public:
    */
   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 );
   }
 
@@ -190,7 +184,7 @@ public:
    */
   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 );
   }
 
@@ -199,25 +193,28 @@ public:
    */
   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:
@@ -227,16 +224,14 @@ 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.
@@ -244,7 +239,7 @@ public:
    */
   bool IsSet() const
   {
-    return mProperty != NULL;
+    return mProperty != nullptr;
   }
 
   /**
@@ -253,7 +248,7 @@ public:
    */
   void Reset()
   {
-    mProperty = NULL;
+    mProperty = nullptr;
   }
 
   /**
@@ -269,45 +264,45 @@ public:
    * @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