Add move semantics to BaseHandle derived classes in Adaptor public API 78/240478/1
authorRichard Huang <r.huang@samsung.com>
Thu, 6 Aug 2020 13:33:51 +0000 (14:33 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 6 Aug 2020 13:33:51 +0000 (14:33 +0100)
Change-Id: I0a8a09dc3e5b72c18a1b23cd99fe4aa056665630

18 files changed:
automated-tests/src/dali-adaptor/utc-Dali-Application.cpp
automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp
dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application.cpp
dali/public-api/adaptor-framework/application.cpp
dali/public-api/adaptor-framework/application.h
dali/public-api/adaptor-framework/timer.cpp
dali/public-api/adaptor-framework/timer.h
dali/public-api/adaptor-framework/tts-player.cpp
dali/public-api/adaptor-framework/tts-player.h
dali/public-api/adaptor-framework/widget-application.cpp
dali/public-api/adaptor-framework/widget-application.h
dali/public-api/adaptor-framework/widget.cpp
dali/public-api/adaptor-framework/widget.h
dali/public-api/adaptor-framework/window.cpp
dali/public-api/adaptor-framework/window.h
dali/public-api/capture/capture.cpp
dali/public-api/capture/capture.h
dali/public-api/watch/watch-application.h

index b37574b..8b97ae5 100644 (file)
@@ -145,6 +145,35 @@ int UtcDaliApplicationCopyAndAssignment(void)
   END_TEST;
 }
 
+int UtcDaliApplicationMoveConstructor(void)
+{
+  Application application = Application::New();
+  DALI_TEST_CHECK( application );
+  DALI_TEST_EQUALS( 1, application.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+
+  Application moved = std::move( application );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( !application );
+
+  END_TEST;
+}
+
+int UtcDaliApplicationMoveAssignment(void)
+{
+  Application application = Application::New();
+  DALI_TEST_CHECK( application );
+  DALI_TEST_EQUALS( 1, application.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+
+  Application moved;
+  moved = std::move( application );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( !application );
+
+  END_TEST;
+}
+
 int UtcDaliApplicationMainLoop01N(void)
 {
   Application application;
index 93e7e44..ecd4831 100644 (file)
@@ -350,6 +350,43 @@ int UtcDaliTimerAssignmentOperator(void)
   END_TEST;
 }
 
+int UtcDaliTimerMoveConstructor(void)
+{
+  AdaptorTestApplication application;
+
+  Timer timer = Timer::New( 40 );
+  DALI_TEST_CHECK( timer );
+  DALI_TEST_EQUALS( 1, timer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( timer.GetInterval() == 40) ;
+
+  Timer moved = std::move( timer );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( moved.GetInterval() == 40 );
+  DALI_TEST_CHECK( !timer );
+
+  END_TEST;
+}
+
+int UtcDaliTimerMoveAssignmentr(void)
+{
+  AdaptorTestApplication application;
+
+  Timer timer = Timer::New( 40 );
+  DALI_TEST_CHECK( timer );
+  DALI_TEST_EQUALS( 1, timer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( timer.GetInterval() == 40) ;
+
+  Timer moved;
+  moved = std::move( timer );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( moved.GetInterval() == 40 );
+  DALI_TEST_CHECK( !timer );
+
+  END_TEST;
+}
+
 int UtcDaliTimerIsRunning(void)
 {
   AdaptorTestApplication application;
index fd5e8a0..b449c67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 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.
@@ -52,19 +52,13 @@ WatchApplication::WatchApplication()
 {
 }
 
-WatchApplication::WatchApplication(const WatchApplication& implementation)
-: Application(implementation)
-{
-}
+WatchApplication::WatchApplication( const WatchApplication& copy ) = default;
 
-WatchApplication& WatchApplication::operator=(const WatchApplication& application)
-{
-  if( *this != application )
-  {
-    BaseHandle::operator=( application );
-  }
-  return *this;
-}
+WatchApplication& WatchApplication::operator=( const WatchApplication& rhs ) = default;
+
+WatchApplication::WatchApplication( WatchApplication&& rhs ) = default;
+
+WatchApplication& WatchApplication::operator=( WatchApplication&& rhs ) = default;
 
 WatchApplication::WatchTimeSignal& WatchApplication::TimeTickSignal()
 {
index b0f7b2a..b7ed5f9 100644 (file)
@@ -137,19 +137,13 @@ Application::Application()
 {
 }
 
-Application::Application(const Application& application)
-: BaseHandle(application)
-{
-}
+Application::Application( const Application& copy ) = default;
 
-Application& Application::operator=(const Application& application)
-{
-  if( *this != application )
-  {
-    BaseHandle::operator=( application );
-  }
-  return *this;
-}
+Application& Application::operator=( const Application& rhs ) = default;
+
+Application::Application( Application&& rhs ) = default;
+
+Application& Application::operator=( Application&& rhs ) = default;
 
 void Application::MainLoop()
 {
index c264e46..d7fb50c 100644 (file)
@@ -213,6 +213,23 @@ public:
   Application& operator=( const Application& application );
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  Application( Application&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Application& operator=( Application&& rhs );
+
+  /**
    * @brief Destructor.
    *
    * This is non-virtual since derived Handle types must not contain data or virtual methods.
index ba98792..6f18b2d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -35,20 +35,13 @@ Timer Timer::New( unsigned int milliSec )
   return Timer(internal.Get());
 }
 
-Timer::Timer( const Timer& timer )
-: BaseHandle(timer)
-{
-}
+Timer::Timer( const Timer& copy ) = default;
 
-Timer& Timer::operator=( const Timer& timer )
-{
-  // check self assignment
-  if( *this != timer )
-  {
-    BaseHandle::operator=(timer);
-  }
-  return *this;
-}
+Timer& Timer::operator=( const Timer& rhs ) = default;
+
+Timer::Timer( Timer&& rhs ) = default;
+
+Timer& Timer::operator=( Timer&& rhs ) = default;
 
 Timer::~Timer()
 {
index edaf556..60134ff 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_TIMER_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.
@@ -98,6 +98,23 @@ public: // API
   Timer& operator=( const Timer& timer );
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  Timer( Timer&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Timer& operator=( Timer&& rhs );
+
+  /**
    * @brief Destructor.
    *
    * This is non-virtual since derived Handle types must not contain data or virtual methods.
index db222bc..6ee0445 100644 (file)
@@ -45,16 +45,13 @@ TtsPlayer::~TtsPlayer()
 {
 }
 
-TtsPlayer::TtsPlayer(const TtsPlayer& handle)
-: BaseHandle(handle)
-{
-}
+TtsPlayer::TtsPlayer( const TtsPlayer& copy ) = default;
 
-TtsPlayer& TtsPlayer::operator=(const TtsPlayer& rhs)
-{
-  BaseHandle::operator=(rhs);
-  return *this;
-}
+TtsPlayer& TtsPlayer::operator=( const TtsPlayer& rhs ) = default;
+
+TtsPlayer::TtsPlayer( TtsPlayer&& rhs ) = default;
+
+TtsPlayer& TtsPlayer::operator=( TtsPlayer&& rhs ) = default;
 
 void TtsPlayer::Play(const std::string& text)
 {
index 55cef69..3979363 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_TTS_PLAYER_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.
@@ -125,6 +125,23 @@ public: // API
   TtsPlayer& operator=(const TtsPlayer& rhs);
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  TtsPlayer( TtsPlayer&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  TtsPlayer& operator=( TtsPlayer&& rhs );
+
+  /**
    * @brief Starts playing the audio data synthesized from the specified text.
    *
    * @SINCE_1_0.0
index 430912d..960ec30 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.
@@ -38,19 +38,13 @@ WidgetApplication::WidgetApplication()
 {
 }
 
-WidgetApplication::WidgetApplication(const WidgetApplication& widgetApplication)
-: Application(widgetApplication)
-{
-}
+WidgetApplication::WidgetApplication( const WidgetApplication& copy ) = default;
 
-WidgetApplication& WidgetApplication::operator=(const WidgetApplication& widgetApplication)
-{
-  if( *this != widgetApplication )
-  {
-    BaseHandle::operator=( widgetApplication );
-  }
-  return *this;
-}
+WidgetApplication& WidgetApplication::operator=( const WidgetApplication& rhs ) = default;
+
+WidgetApplication::WidgetApplication( WidgetApplication&& rhs ) = default;
+
+WidgetApplication& WidgetApplication::operator=( WidgetApplication&& rhs ) = default;
 
 void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction )
 {
index cf71d05..6acfe75 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_WIDGET_APPLICATION_H
 
 /*
- * Copyright (c) 2018 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.
@@ -147,6 +147,23 @@ public:
    */
   WidgetApplication& operator=( const WidgetApplication& widgetApplication );
 
+  /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  WidgetApplication( WidgetApplication&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  WidgetApplication& operator=( WidgetApplication&& rhs );
+
  /**
    * @brief Destructor
    * @SINCE_1_3_5
index bc8d070..7398747 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.
@@ -38,19 +38,13 @@ Widget::Widget()
 {
 }
 
-Widget::Widget(const Widget& widget)
-: BaseHandle(widget)
-{
-}
+Widget::Widget( const Widget& copy ) = default;
 
-Widget& Widget::operator=(const Widget& widget)
-{
-  if( *this != widget )
-  {
-    BaseHandle::operator=( widget );
-  }
-  return *this;
-}
+Widget& Widget::operator=( const Widget& rhs ) = default;
+
+Widget::Widget( Widget&& rhs ) = default;
+
+Widget& Widget::operator=( Widget&& rhs ) = default;
 
 Widget::Widget(Internal::Adaptor::Widget* widget)
 : BaseHandle(widget)
index 9332298..c00a914 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_WIDGET_H
 
 /*
- * Copyright (c) 2018 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.
@@ -95,6 +95,23 @@ public:
   Widget& operator=( const Widget& widget );
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  Widget( Widget&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Widget& operator=( Widget&& rhs );
+
+  /**
    * @brief Destructor
    * @SINCE_1_3_5
    */
index c073254..8a15192 100644 (file)
@@ -76,16 +76,13 @@ Window::~Window()
 {
 }
 
-Window::Window(const Window& handle)
-: BaseHandle(handle)
-{
-}
+Window::Window( const Window& copy ) = default;
 
-Window& Window::operator=(const Window& rhs)
-{
-  BaseHandle::operator=(rhs);
-  return *this;
-}
+Window& Window::operator=( const Window& rhs ) = default;
+
+Window::Window( Window&& rhs ) = default;
+
+Window& Window::operator=( Window&& rhs ) = default;
 
 void Window::Add( Dali::Actor actor )
 {
index 05a86de..8105e5d 100644 (file)
@@ -210,6 +210,23 @@ public:
   Window& operator=(const Window& rhs);
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  Window( Window&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Window& operator=( Window&& rhs );
+
+  /**
    * @brief Adds a child Actor to the Window.
    *
    * The child will be referenced.
index ca7c098..9d288e8 100644 (file)
@@ -51,16 +51,13 @@ Capture::~Capture()
 {
 }
 
-Capture::Capture( const Capture& copy )
-: BaseHandle(copy)
-{
-}
+Capture::Capture( const Capture& copy ) = default;
 
-Capture& Capture::operator=( const Capture& rhs )
-{
-  BaseHandle::operator=( rhs );
-  return *this;
-}
+Capture& Capture::operator=( const Capture& rhs ) = default;
+
+Capture::Capture( Capture&& rhs ) = default;
+
+Capture& Capture::operator=( Capture&& rhs ) = default;
 
 void Capture::Start( Actor source, const Vector2& size, const std::string &path, const Vector4& clearColor, const uint32_t quality )
 {
index 73afb16..7113eee 100755 (executable)
@@ -169,6 +169,23 @@ public:
   Capture& operator=( const Capture& rhs );
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  Capture( Capture&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Capture& operator=( Capture&& rhs );
+
+  /**
    * @brief Start capture and save the image as a file.
    *
    * @SINCE_1_9.12
index df59ef5..1900593 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_WATCH_APPLICATION_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.
@@ -152,6 +152,23 @@ public:
   WatchApplication& operator=( const WatchApplication& application );
 
   /**
+   * @brief Move constructor.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   */
+  WatchApplication( WatchApplication&& rhs );
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.24
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  WatchApplication& operator=( WatchApplication&& rhs );
+
+  /**
    * @brief Destructor
    *
    * This is non-virtual since derived Handle types must not contain data or virtual methods.