Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-input-impl.h
index 970f18b..996fde7 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__
-#define __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__
+#ifndef DALI_INTERNAL_PROPERTY_INPUT_IMPL_H
+#define DALI_INTERNAL_PROPERTY_INPUT_IMPL_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.
 #include <dali/public-api/math/matrix.h>
 #include <dali/internal/common/buffer-index.h>
 
+#if defined (ANDROID) || defined(WIN32) || defined(__APPLE__)
+namespace std
+{
+
+uint64_t _Hash_bytes(const void* bytes, uint64_t size, uint64_t seed);
+
+}
+#endif
+
 namespace Dali
 {
 
@@ -48,9 +57,7 @@ public:
   /**
    * Virtual destructor.
    */
-  virtual ~PropertyInputImpl()
-  {
-  }
+  virtual ~PropertyInputImpl() = default;
 
   /**
    * Query the type of property input.
@@ -78,8 +85,7 @@ public:
    */
   virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const bool&>(*this);
   }
 
@@ -91,8 +97,7 @@ public:
    */
   virtual const int& GetInteger( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const int&>(*this);
   }
 
@@ -104,8 +109,7 @@ public:
    */
   virtual const float& GetFloat( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const float&>(*this);
   }
 
@@ -117,8 +121,7 @@ public:
    */
   virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Vector2&>(*this);
   }
 
@@ -130,8 +133,7 @@ public:
    */
   virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Vector3&>(*this);
   }
 
@@ -143,8 +145,7 @@ public:
    */
   virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Vector4&>(*this);
   }
 
@@ -156,8 +157,7 @@ public:
    */
   virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Quaternion&>(*this);
   }
 
@@ -169,8 +169,7 @@ public:
    */
   virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Matrix3&>(*this);
   }
 
@@ -182,8 +181,7 @@ public:
    */
   virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
   {
-    DALI_ASSERT_ALWAYS( false && "Property type mismatch" );
-    // the return will never be executed due to assert above so just keep the compiler happy
+    // the return will never be executed, it's just to keep the compiler happy
     return reinterpret_cast<const Matrix&>(*this);
   }
 
@@ -307,6 +305,73 @@ public:
   }
 
   /**
+   * Query whether the property belongs to the
+   * transform manager or not.
+   * @return True if it is a transform manager property, false otherwise
+   */
+  virtual bool IsTransformManagerProperty() const
+  {
+    return false;
+  }
+
+  std::uint64_t Hash(BufferIndex bufferIndex, uint64_t seed) const
+  {
+    switch ( GetType() )
+    {
+      case Property::BOOLEAN:
+      {
+        return std::_Hash_bytes(&GetBoolean(bufferIndex), sizeof(bool), seed);
+      }
+
+      case Property::INTEGER:
+      {
+        return std::_Hash_bytes(&GetInteger(bufferIndex), sizeof(int), seed);
+      }
+
+      case Property::FLOAT:
+      {
+        return std::_Hash_bytes(&GetFloat(bufferIndex), sizeof(float), seed);
+      }
+
+      case Property::VECTOR2:
+      {
+        return std::_Hash_bytes(&GetVector2(bufferIndex), sizeof(Vector2), seed);
+      }
+
+      case Property::VECTOR3:
+      {
+        return std::_Hash_bytes(&GetVector3(bufferIndex), sizeof(Vector3), seed);
+      }
+
+      case Property::VECTOR4:
+      {
+        return std::_Hash_bytes(&GetVector4(bufferIndex), sizeof(Vector4), seed);
+      }
+
+      case Property::ROTATION:
+      {
+        return std::_Hash_bytes(&GetQuaternion(bufferIndex), sizeof(Quaternion), seed);
+      }
+
+      case Property::MATRIX:
+      {
+        return std::_Hash_bytes(&GetMatrix(bufferIndex), sizeof(Matrix), seed);
+      }
+
+      case Property::MATRIX3:
+      {
+        return std::_Hash_bytes(&GetMatrix3(bufferIndex), sizeof(Matrix3), seed);
+      }
+
+      default:
+        break; // print nothing
+    }
+
+    return seed;
+  }
+
+
+  /**
    * Print the property value using a stream.
    * @param[in] debugStream The output stream.
    * @param[in] bufferIndex The buffer to read from.
@@ -380,4 +445,4 @@ public:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__
+#endif // DALI_INTERNAL_PROPERTY_INPUT_IMPL_H