Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / property-input-accessor.h
index 8c37e0a..482d1ca 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_PROPERTY_INPUT_ACCESSOR_H__
-#define __DALI_PROPERTY_INPUT_ACCESSOR_H__
+#ifndef DALI_PROPERTY_INPUT_ACCESSOR_H
+#define DALI_PROPERTY_INPUT_ACCESSOR_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.
@@ -36,7 +36,7 @@ public:
    * Create the PropertyInputAccessor.
    */
   PropertyInputAccessor()
-  : mInput( NULL ),
+  : mInput( nullptr ),
     mComponentIndex( -1 )
   {
   }
@@ -44,7 +44,7 @@ public:
   /**
    * Create the PropertyInputAccessor.
    */
-  PropertyInputAccessor( const PropertyInputImpl* input, int componentIndex )
+  PropertyInputAccessor( const PropertyInputImpl* input, int32_t componentIndex )
   : mInput( input ),
     mComponentIndex( componentIndex )
   {
@@ -53,26 +53,25 @@ public:
   /**
    * Copy from a PropertyInputAccessor
    */
-  PropertyInputAccessor( const PropertyInputAccessor& accessor )
-  : mInput( accessor.mInput ),
-    mComponentIndex( accessor.mComponentIndex )
-  {
-  }
+  PropertyInputAccessor(const PropertyInputAccessor& accessor) = default;
 
   /**
    * Copy from a PropertyInputAccessor
    */
   PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
   {
-    mInput = accessor.mInput;
-    mComponentIndex = accessor.mComponentIndex;
+    if( this != &accessor )
+    {
+      mInput = accessor.mInput;
+      mComponentIndex = accessor.mComponentIndex;
+    }
     return *this;
   }
 
   /**
    * Set the property input.
    */
-  void SetInput( const PropertyInputImpl& input, int componentIndex )
+  void SetInput( const PropertyInputImpl& input, int32_t componentIndex )
   {
     mInput = &input;
     mComponentIndex = componentIndex;
@@ -103,6 +102,16 @@ public:
   }
 
   /**
+   * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
+   */
+  const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
+  {
+    DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
+
+    return mInput->GetConstraintInputInteger( updateBufferIndex );
+  }
+
+  /**
    * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
    */
   const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
@@ -110,9 +119,19 @@ public:
     // Invalid index is ok
     if ( mComponentIndex < 0 )
     {
-      // Not a Vector3 or Vector4 component, expecting float type
+      // Not a Vector2, Vector3 or Vector4 component, expecting float type
       return mInput->GetConstraintInputFloat( updateBufferIndex );
     }
+    else if ( PropertyTypes::Get< Vector2 >() == mInput->GetType() )
+    {
+      if ( 0 == mComponentIndex )
+      {
+        return mInput->GetConstraintInputVector2( updateBufferIndex ).x;
+      }
+
+      DALI_ASSERT_DEBUG( 1 == mComponentIndex && "Invalid Vector2 component index" );
+      return mInput->GetConstraintInputVector2( updateBufferIndex ).y;
+    }
     else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
     {
       if ( 0 == mComponentIndex )
@@ -139,7 +158,7 @@ public:
     }
     else if ( 2 == mComponentIndex )
     {
-      return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
+      return mInput->GetConstraintInputVector4( updateBufferIndex ).z;
     }
 
     DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
@@ -147,14 +166,6 @@ public:
   }
 
   /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
-   */
-  const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
-  {
-    return mInput->GetConstraintInputInteger( updateBufferIndex );
-  }
-
-  /**
    * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
    */
   const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
@@ -205,11 +216,12 @@ public:
 public:
 
   const PropertyInputImpl* mInput;
-  int mComponentIndex;
+  int32_t mComponentIndex;
+
 };
 
 } // namespace Internal
 
 } // namespace Dali
 
-#endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__
+#endif // DALI_PROPERTY_INPUT_ACCESSOR_H