Make Dali::Vector movable & add use Modern C++ semantics on public & devel classes 07/240707/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 10 Aug 2020 16:57:37 +0000 (17:57 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 10 Aug 2020 17:19:22 +0000 (18:19 +0100)
Change-Id: Idf04221c2700728d81510036da5013d3253419bf

13 files changed:
automated-tests/src/dali/utc-Dali-Vector.cpp
dali/devel-api/common/owner-container.h
dali/devel-api/common/ref-counted-dali-vector.h
dali/devel-api/threading/thread.h
dali/public-api/animation/constraint.h
dali/public-api/common/dali-vector.h
dali/public-api/object/base-object.h
dali/public-api/signals/base-signal.h
dali/public-api/signals/connection-tracker-interface.h
dali/public-api/signals/connection-tracker.h
dali/public-api/signals/dali-signal.h
dali/public-api/signals/signal-slot-connections.h
dali/public-api/signals/slot-delegate.h

index c7fbe71..330b442 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -1360,6 +1360,37 @@ int UtcDaliVectorCpp11ForP(void)
   END_TEST;
 }
 
+int UtcDaliVectorMoveConstructor(void)
+{
+  Vector<Vector3> movedFrom;
+  movedFrom.PushBack(Vector3::ONE);
+  movedFrom.PushBack(Vector3::NEGATIVE_YAXIS);
+  movedFrom.PushBack(Vector3::NEGATIVE_ZAXIS);
+
+  Vector<Vector3> movedTo(std::move(movedFrom));
+  DALI_TEST_EQUALS( movedTo.Size(), 3u, TEST_LOCATION);
+  DALI_TEST_EQUALS( movedFrom.Size(), 0u, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliVectorMoveAssignment(void)
+{
+  Vector<Vector3> movedFrom;
+  movedFrom.PushBack(Vector3::ONE);
+  movedFrom.PushBack(Vector3::NEGATIVE_YAXIS);
+  movedFrom.PushBack(Vector3::NEGATIVE_ZAXIS);
+
+  Vector<Vector3> movedTo;
+  DALI_TEST_EQUALS(movedTo.Size(), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS(movedFrom.Size(), 3u, TEST_LOCATION);
+
+  movedTo = std::move(movedFrom);
+  DALI_TEST_EQUALS(movedTo.Size(), 3u, TEST_LOCATION);
+  DALI_TEST_EQUALS(movedFrom.Size(), 0u, TEST_LOCATION);
+
+  END_TEST;
+}
 
 /*
  * this does not compile at the moment
index 62d59c1..5637d57 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_OWNER_CONTAINER_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -62,6 +62,12 @@ public:
     VectorBase::Release();
   }
 
+  // Not copyable or movable
+  OwnerContainer( const OwnerContainer& ) = delete; ///< Deleted copy constructor
+  OwnerContainer( OwnerContainer&& ) = delete; ///< Deleted move constructor
+  OwnerContainer& operator=( const OwnerContainer& ) = delete; ///< Deleted copy assignment operator
+  OwnerContainer& operator=( OwnerContainer&& ) = delete; ///< Deleted move assignment operator
+
   /**
    * Test whether the container is empty.
    * @return True if the container is empty
@@ -181,11 +187,6 @@ public:
 
 private:
 
-  // Undefined copy constructor.
-  OwnerContainer( const OwnerContainer& );
-  // Undefined assignment operator.
-  OwnerContainer& operator=( const OwnerContainer& );
-
   /**
    * @brief delete the contents of the pointer
    * Function provided to allow classes to provide a custom destructor through template specialisation
index c6d57c9..0c869c7 100644 (file)
@@ -2,7 +2,7 @@
 #define REF_COUNTED_DALI_VECTOR_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -55,15 +55,18 @@ public:
     return mVector;
   }
 
+  // Not copyable or movable
+  RefCountedVector( const RefCountedVector& ) = delete; ///< Deleted copy constructor
+  RefCountedVector( RefCountedVector&& ) = delete; ///< Deleted move constructor
+  RefCountedVector& operator=( const RefCountedVector& ) = delete; ///< Deleted copy assignment operator
+  RefCountedVector& operator=( RefCountedVector&& ) = delete; ///< Deleted move assignment operator
+
 protected:
   virtual ~RefCountedVector()
   {
   }
 
 private:
-  // Disable copy-constructing and copying:
-  RefCountedVector(const RefCountedVector &); ///< Undefined
-  RefCountedVector & operator = (const RefCountedVector &); ///< Undefined
 
   Vector< T > mVector; ///< The vector of data
 };
index be66c95..1427482 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_THREAD_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -69,10 +69,11 @@ private:
    */
   static void InternalThreadEntryFunc( Thread& This );
 
-  // Undefined
-  Thread( const Thread& );
-  // Undefined
-  const Thread& operator=( const Thread& );
+  // Not copyable or movable
+  Thread( const Thread& ) = delete; ///< Deleted copy constructor
+  Thread( Thread&& ) = delete; ///< Deleted move constructor
+  Thread& operator=( const Thread& ) = delete; ///< Deleted copy assignment operator
+  Thread& operator=( Thread&& ) = delete; ///< Deleted move assignment operator
 
 private:
 
index 170ba8e..57c0aa3 100644 (file)
@@ -225,17 +225,10 @@ public:
       }
     };
 
-    /**
-     * @brief Undefined copy constructor.
-     * @SINCE_1_0.0
-     */
-    Function( const Function& );
-
-    /**
-     * @brief Undefined assignment operator.
-     * @SINCE_1_0.0
-     */
-    Function& operator=( const Function& );
+    Function( const Function& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+    Function( Function&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+    Function& operator=( const Function& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+    Function& operator=( Function&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 
     /**
      * @brief Constructor used when copying the stored object.
index 98fae38..9ae40e2 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_VECTOR_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -211,8 +211,12 @@ protected: // for Derived classes
 private:
 
   // not copyable as it does not know the size of elements
-  VectorBase( const VectorBase& ); ///< Undefined @SINCE_1_0.0
-  VectorBase& operator=( const VectorBase& ); ///< Undefined @SINCE_1_0.0
+  VectorBase( const VectorBase& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  VectorBase& operator=( const VectorBase& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+
+  // not movable as this is handled by deriving classes
+  VectorBase( VectorBase&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  VectorBase& operator=( VectorBase&& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_9.25
 
 protected: // Data
 
@@ -454,11 +458,23 @@ public: // API
    */
   Vector( const Vector& vector )
   {
-    // reuse assignment
+    // reuse copy assignment
     operator=( vector );
   }
 
   /**
+   * @brief Default move constructor.
+   *
+   * @SINCE_1_9.25
+   * @param[in] vector Vector to move
+   */
+  Vector( Vector&& vector )
+  {
+    // reuse move assignment
+    operator=( std::move( vector ) );
+  }
+
+  /**
    * @brief Assignment operator.
    *
    * @SINCE_1_0.0
@@ -475,6 +491,26 @@ public: // API
   }
 
   /**
+   * @brief Default move assignment operator.
+   *
+   * @SINCE_1_9.25
+   * @param[in] vector Vector to move
+   */
+  Vector& operator=( Vector&& vector )
+  {
+    if( this != &vector )
+    {
+      if( VectorBase::mData )
+      {
+        Release();
+      }
+      VectorBase::mData = vector.mData;
+      vector.mData = nullptr;
+    }
+    return *this;
+  }
+
+  /**
    * @brief Iterator to the beginning of the data.
    * @SINCE_1_0.0
    * @return Iterator to the beginning of the data
index 87bf3c9..5a42fc9 100644 (file)
@@ -114,13 +114,12 @@ protected:
    */
   void UnregisterObject();
 
-private:
-
-  // Not implemented
-  DALI_INTERNAL BaseObject(const BaseObject& rhs);
+  // Not copyable or movable
 
-  // Not implemented
-  DALI_INTERNAL BaseObject& operator=(const BaseObject& rhs);
+  BaseObject(const BaseObject& rhs) = delete; ///< Deleted copy constructor
+  BaseObject(BaseObject&& rhs) = delete; ///< Deleted move constructor
+  BaseObject& operator=(const BaseObject& rhs) = delete; ///< Deleted copy assignment operator
+  BaseObject& operator=(BaseObject&& rhs) = delete; ///< Deleted move assignment operator
 
 public:
 
index f127d1d..a2e17ac 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_BASE_SIGNAL_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -511,8 +511,10 @@ private:
    */
   void CleanupConnections();
 
-  BaseSignal( const BaseSignal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  BaseSignal& operator=( const BaseSignal& );        ///< undefined assignment operator @SINCE_1_0.0
+  BaseSignal( const BaseSignal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  BaseSignal( BaseSignal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  BaseSignal& operator=( const BaseSignal& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  BaseSignal& operator=( BaseSignal&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 
 private:
 
index 849ea22..c9093f3 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_CONNECTION_TRACKER_INTERFACE_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -78,8 +78,10 @@ public:
 
 private:
 
-  ConnectionTrackerInterface( const ConnectionTrackerInterface& );            ///< undefined copy constructor @SINCE_1_0.0
-  ConnectionTrackerInterface& operator=( const ConnectionTrackerInterface& ); ///< undefined assignment operator @SINCE_1_0.0
+  ConnectionTrackerInterface( const ConnectionTrackerInterface& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  ConnectionTrackerInterface( ConnectionTrackerInterface&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  ConnectionTrackerInterface& operator=( const ConnectionTrackerInterface& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  ConnectionTrackerInterface& operator=( ConnectionTrackerInterface&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 };
 
 /**
index 6c690f1..7da099f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_CONNECTION_TRACKER_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -79,8 +79,10 @@ public:
 
 private:
 
-  ConnectionTracker( const ConnectionTracker& );            ///< undefined copy constructor @SINCE_1_0.0
-  ConnectionTracker& operator=( const ConnectionTracker& ); ///< undefined assignment operator @SINCE_1_0.0
+  ConnectionTracker( const ConnectionTracker& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  ConnectionTracker( ConnectionTracker&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  ConnectionTracker& operator=( const ConnectionTracker& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  ConnectionTracker& operator=( ConnectionTracker&& ) = delete;///< Deleted move assignment operator. @SINCE_1_9.25
 
 private:
 
index 75eb45e..4812ca9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SIGNAL_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -294,8 +294,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -461,8 +463,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -628,8 +632,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -796,8 +802,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -967,8 +975,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -1135,8 +1145,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -1304,8 +1316,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
@@ -1475,8 +1489,10 @@ public:
 
 private:
 
-  Signal( const Signal& );                   ///< undefined copy constructor, signals don't support copying. @SINCE_1_0.0
-  Signal& operator=( const Signal& );        ///< undefined assignment operator @SINCE_1_0.0
+  Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0
+  Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25
+  Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0
+  Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25
 
 private:
 
index e3b1e76..d21e088 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SIGNAL_SLOT_CONNECTIONS_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -80,8 +80,10 @@ public:
 
 private:
 
-  SlotConnection( const SlotConnection& );            ///< undefined copy constructor @SINCE_1_0.0
-  SlotConnection& operator=( const SlotConnection& ); ///< undefined assignment operator @SINCE_1_0.0
+  SlotConnection( const SlotConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  SlotConnection( SlotConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  SlotConnection& operator=( const SlotConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  SlotConnection& operator=( SlotConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 
 private:
 
@@ -148,8 +150,10 @@ public:
 
 private:
 
-  SignalConnection( const SignalConnection& );            ///< undefined copy constructor @SINCE_1_0.0
-  SignalConnection& operator=( const SignalConnection& ); ///< undefined assignment operator @SINCE_1_0.0
+  SignalConnection( const SignalConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  SignalConnection( SignalConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  SignalConnection& operator=( const SignalConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  SignalConnection& operator=( SignalConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 
 private:
 
index 405ed65..251a2d8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SLOT_DELEGATE_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -139,8 +139,10 @@ public:
 
 private:
 
-  SlotDelegate( const SlotDelegate& );            ///< undefined copy constructor @SINCE_1_0.0
-  SlotDelegate& operator=( const SlotDelegate& ); ///< undefined assignment operator @SINCE_1_0.0
+  SlotDelegate( const SlotDelegate& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0
+  SlotDelegate( SlotDelegate&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25
+  SlotDelegate& operator=( const SlotDelegate& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0
+  SlotDelegate& operator=( SlotDelegate&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
 
 private: