Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / common / inherited-property.h
index 6a13c24..dc3559f 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H
+#define DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_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.
@@ -27,6 +27,7 @@
 #include <dali/public-api/object/property.h>
 #include <dali/public-api/object/property-input.h>
 #include <dali/public-api/object/property-types.h>
+#include <dali/public-api/math/math-utils.h> // Clamp
 
 namespace Dali
 {
@@ -37,39 +38,42 @@ namespace Internal
 namespace SceneGraph
 {
 
-template <class T>
-class InheritedProperty;
-
 /**
  * An inherited Vector3 property.
  */
-template <>
-class InheritedProperty<Vector3> : public PropertyInputImpl
+class InheritedVector3 : public PropertyInputImpl
 {
 public:
 
   /**
-   * Create an inherited property.
-   * @param [in] initialValue The initial value of the property.
+   * Create an inherited Vector3.
    */
-  InheritedProperty( const Vector3& initialValue )
-  : mValue( initialValue ),
+  InheritedVector3()
+  : mValue(),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
   }
 
   /**
-   * Virtual destructor.
+   * Create an inherited Vector3.
+   * @param [in] initialValue The initial value of the property.
    */
-  virtual ~InheritedProperty()
+  InheritedVector3( const Vector3& initialValue )
+  : mValue( initialValue ),
+    mInheritedFlag( false ),
+    mReinheritedFlag( true )
   {
   }
+  /**
+   * Virtual destructor.
+   */
+  ~InheritedVector3() override = default;
 
   /**
    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
    */
-  virtual Dali::Property::Type GetType() const
+  Dali::Property::Type GetType() const override
   {
     return Dali::PropertyTypes::Get<Vector3>();
   }
@@ -99,7 +103,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
    */
-  virtual bool InputInitialized() const
+  bool InputInitialized() const override
   {
     // A constraint cannot use the property until it has been inherited (at least once).
     return mInheritedFlag;
@@ -109,7 +113,7 @@ public:
    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
    * @note A constraint can only receive the inherited property from the previous frame.
    */
-  virtual bool InputChanged() const
+  bool InputChanged() const override
   {
     return !IsClean();
   }
@@ -117,7 +121,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetVector3()
    */
-  virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
+  const Vector3& GetVector3( BufferIndex bufferIndex ) const override
   {
     return mValue[ bufferIndex ];
   }
@@ -125,7 +129,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputVector3()
    */
-  virtual const Vector3& GetConstraintInputVector3( BufferIndex bufferIndex ) const
+  const Vector3& GetConstraintInputVector3( BufferIndex bufferIndex ) const override
   {
     // For inherited properties, constraints work with the value from the previous frame.
     // This is because constraints are applied to position etc, before world-position is calculated.
@@ -153,7 +157,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Vector3& Get(size_t bufferIndex)
+  Vector3& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -161,7 +165,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Vector3& Get(size_t bufferIndex) const
+  const Vector3& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -171,7 +175,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Vector3& operator[](size_t bufferIndex) const
+  const Vector3& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -179,10 +183,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty(const InheritedProperty& property);
+  InheritedVector3(const InheritedVector3& property);
 
   // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedVector3& operator=(const InheritedVector3& rhs);
 
 private:
 
@@ -213,14 +217,12 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedColor()
-  {
-  }
+  ~InheritedColor() override = default;
 
   /**
    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
    */
-  virtual Dali::Property::Type GetType() const
+  Dali::Property::Type GetType() const override
   {
     return Dali::PropertyTypes::Get<Vector4>();
   }
@@ -250,7 +252,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
    */
-  virtual bool InputInitialized() const
+  bool InputInitialized() const override
   {
     // A constraint cannot use the property until it has been inherited (at least once).
     return mInheritedFlag;
@@ -260,7 +262,7 @@ public:
    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
    * @note A constraint can only receive the inherited property from the previous frame.
    */
-  virtual bool InputChanged() const
+  bool InputChanged() const override
   {
     return !IsClean();
   }
@@ -268,7 +270,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetVector4()
    */
-  virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
+  const Vector4& GetVector4( BufferIndex bufferIndex ) const override
   {
     return mValue[ bufferIndex ];
   }
@@ -276,7 +278,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputVector4()
    */
-  virtual const Vector4& GetConstraintInputVector4( BufferIndex bufferIndex ) const
+  const Vector4& GetConstraintInputVector4( BufferIndex bufferIndex ) const override
   {
     // For inherited properties, constraints work with the value from the previous frame.
     // This is because constraints are applied to position etc, before world-position is calculated.
@@ -324,7 +326,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Vector4& Get(size_t bufferIndex)
+  Vector4& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -332,7 +334,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Vector4& Get(size_t bufferIndex) const
+  const Vector4& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -342,7 +344,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Vector4& operator[](size_t bufferIndex) const
+  const Vector4& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -360,23 +362,20 @@ private:
 
   bool mInheritedFlag   :1; ///< Flag whether the value has ever been inherited
   bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
-
 };
 
 /**
  * An inherited Quaternion property.
  */
-template <>
-class InheritedProperty<Quaternion> : public PropertyInputImpl
+class InheritedQuaternion : public PropertyInputImpl
 {
 public:
 
   /**
    * Create an inherited property.
-   * @param [in] initialValue The initial value of the property.
    */
-  InheritedProperty( const Quaternion& initialValue )
-  : mValue( initialValue ),
+  InheritedQuaternion()
+  : mValue(),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
@@ -385,14 +384,12 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedProperty()
-  {
-  }
+  ~InheritedQuaternion() override = default;
 
   /**
    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
    */
-  virtual Dali::Property::Type GetType() const
+  Dali::Property::Type GetType() const override
   {
     return Dali::PropertyTypes::Get<Quaternion>();
   }
@@ -422,7 +419,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
    */
-  virtual bool InputInitialized() const
+  bool InputInitialized() const override
   {
     // A constraint cannot use the property until it has been inherited (at least once).
     return mInheritedFlag;
@@ -432,7 +429,7 @@ public:
    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
    * @note A constraint can only receive the inherited property from the previous frame.
    */
-  virtual bool InputChanged() const
+  bool InputChanged() const override
   {
     return !IsClean();
   }
@@ -440,7 +437,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetQuaternion()
    */
-  virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
+  const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override
   {
     return mValue[ bufferIndex ];
   }
@@ -448,7 +445,7 @@ public:
   /**
    * @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
    */
-  virtual const Quaternion& GetConstraintInputQuaternion( BufferIndex bufferIndex ) const
+  const Quaternion& GetConstraintInputQuaternion( BufferIndex bufferIndex ) const override
   {
     // For inherited properties, constraints work with the value from the previous frame.
     // This is because constraints are applied to position etc, before world-position is calculated.
@@ -476,7 +473,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Quaternion& Get(size_t bufferIndex)
+  Quaternion& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -484,7 +481,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Quaternion& Get(size_t bufferIndex) const
+  const Quaternion& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -494,7 +491,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Quaternion& operator[](size_t bufferIndex) const
+  const Quaternion& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -502,13 +499,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty();
+  InheritedQuaternion(const InheritedQuaternion& property);
 
   // Undefined
-  InheritedProperty(const InheritedProperty& property);
-
-  // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedQuaternion& operator=(const InheritedQuaternion& rhs);
 
 private:
 
@@ -521,17 +515,15 @@ private:
 /**
  * An inherited Matrix property.
  */
-template <>
-class InheritedProperty<Matrix> : public PropertyInputImpl
+class InheritedMatrix : public PropertyInputImpl
 {
 public:
 
   /**
    * Create an inherited property.
-   * @param [in] initialValue The initial value of the property.
    */
-  InheritedProperty( const Matrix& initialValue )
-  : mValue( initialValue ),
+  InheritedMatrix()
+  : mValue(),
     mInheritedFlag( false ),
     mReinheritedFlag( true )
   {
@@ -540,14 +532,12 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~InheritedProperty()
-  {
-  }
+  ~InheritedMatrix() override = default;
 
   /**
    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
    */
-  virtual Dali::Property::Type GetType() const
+  Dali::Property::Type GetType() const override
   {
     return Dali::PropertyTypes::Get<Matrix>();
   }
@@ -577,7 +567,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
    */
-  virtual bool InputInitialized() const
+  bool InputInitialized() const override
   {
     // A constraint cannot use the property until it has been inherited (at least once).
     return mInheritedFlag;
@@ -587,7 +577,7 @@ public:
    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
    * @note A constraint can only receive the inherited property from the previous frame.
    */
-  virtual bool InputChanged() const
+  bool InputChanged() const override
   {
     return !IsClean();
   }
@@ -595,7 +585,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
    */
-  virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
+  const Matrix& GetMatrix( BufferIndex bufferIndex ) const override
   {
     return mValue[ bufferIndex ];
   }
@@ -603,7 +593,7 @@ public:
   /**
    * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
    */
-  virtual const Matrix& GetConstraintInputMatrix( BufferIndex bufferIndex ) const
+  const Matrix& GetConstraintInputMatrix( BufferIndex bufferIndex ) const override
   {
     // For inherited properties, constraints work with the value from the previous frame.
     // This is because constraints are applied to position etc, before world-position is calculated.
@@ -613,24 +603,6 @@ public:
   }
 
   /**
-   * @copydoc Dali::PropertyInput::GetQuaternion()
-   */
-  virtual const Quaternion& GetQuaternion() const
-  {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    return DUMMY_QUATERNION_VALUE;
-  }
-
-  /**
-   * @copydoc Dali::PropertyInput::GetQuaternion()
-   */
-  virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
-  {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    return DUMMY_QUATERNION_VALUE;
-  }
-
-  /**
    * Set the property value. This will only persist for the current frame; the property
    * will be reset with the base value, at the beginning of the next frame.
    * @param[in] bufferIndex The buffer to write.
@@ -649,7 +621,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  Matrix& Get(size_t bufferIndex)
+  Matrix& Get( BufferIndex bufferIndex )
   {
     return mValue[bufferIndex];
   }
@@ -657,7 +629,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::PropertyInterface::Get()
    */
-  const Matrix& Get(size_t bufferIndex) const
+  const Matrix& Get( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
@@ -667,12 +639,12 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const Matrix& operator[](size_t bufferIndex) const
+  const Matrix& operator[]( BufferIndex bufferIndex ) const
   {
     return mValue[bufferIndex];
   }
 
-  void SetDirty(size_t bufferIndex)
+  void SetDirty( BufferIndex bufferIndex )
   {
     mReinheritedFlag = true;
 
@@ -683,13 +655,10 @@ public:
 private:
 
   // Undefined
-  InheritedProperty();
-
-  // Undefined
-  InheritedProperty(const InheritedProperty& property);
+  InheritedMatrix(const InheritedMatrix& property);
 
   // Undefined
-  InheritedProperty& operator=(const InheritedProperty& rhs);
+  InheritedMatrix& operator=(const InheritedMatrix& rhs);
 
 private:
 
@@ -706,4 +675,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H