From: Richard Huang Date: Thu, 6 Aug 2020 13:33:51 +0000 (+0100) Subject: Add move semantics to BaseHandle derived classes in Adaptor public API X-Git-Tag: dali_1.9.24~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=120d7c61675fc26af8f2f9fc579a5ba82e53f960 Add move semantics to BaseHandle derived classes in Adaptor public API Change-Id: I0a8a09dc3e5b72c18a1b23cd99fe4aa056665630 --- diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp index b37574b..8b97ae5 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Application.cpp @@ -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; diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp index 93e7e44..ecd4831 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp @@ -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; diff --git a/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application.cpp b/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application.cpp index fd5e8a0..b449c67 100644 --- a/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application.cpp +++ b/dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application.cpp @@ -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() { diff --git a/dali/public-api/adaptor-framework/application.cpp b/dali/public-api/adaptor-framework/application.cpp index b0f7b2a..b7ed5f9 100644 --- a/dali/public-api/adaptor-framework/application.cpp +++ b/dali/public-api/adaptor-framework/application.cpp @@ -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() { diff --git a/dali/public-api/adaptor-framework/application.h b/dali/public-api/adaptor-framework/application.h index c264e46..d7fb50c 100644 --- a/dali/public-api/adaptor-framework/application.h +++ b/dali/public-api/adaptor-framework/application.h @@ -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. diff --git a/dali/public-api/adaptor-framework/timer.cpp b/dali/public-api/adaptor-framework/timer.cpp index ba98792..6f18b2d 100644 --- a/dali/public-api/adaptor-framework/timer.cpp +++ b/dali/public-api/adaptor-framework/timer.cpp @@ -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() { diff --git a/dali/public-api/adaptor-framework/timer.h b/dali/public-api/adaptor-framework/timer.h index edaf556..60134ff 100755 --- a/dali/public-api/adaptor-framework/timer.h +++ b/dali/public-api/adaptor-framework/timer.h @@ -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. diff --git a/dali/public-api/adaptor-framework/tts-player.cpp b/dali/public-api/adaptor-framework/tts-player.cpp index db222bc..6ee0445 100644 --- a/dali/public-api/adaptor-framework/tts-player.cpp +++ b/dali/public-api/adaptor-framework/tts-player.cpp @@ -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) { diff --git a/dali/public-api/adaptor-framework/tts-player.h b/dali/public-api/adaptor-framework/tts-player.h index 55cef69..3979363 100755 --- a/dali/public-api/adaptor-framework/tts-player.h +++ b/dali/public-api/adaptor-framework/tts-player.h @@ -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 diff --git a/dali/public-api/adaptor-framework/widget-application.cpp b/dali/public-api/adaptor-framework/widget-application.cpp index 430912d..960ec30 100644 --- a/dali/public-api/adaptor-framework/widget-application.cpp +++ b/dali/public-api/adaptor-framework/widget-application.cpp @@ -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 ) { diff --git a/dali/public-api/adaptor-framework/widget-application.h b/dali/public-api/adaptor-framework/widget-application.h index cf71d05..6acfe75 100644 --- a/dali/public-api/adaptor-framework/widget-application.h +++ b/dali/public-api/adaptor-framework/widget-application.h @@ -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 diff --git a/dali/public-api/adaptor-framework/widget.cpp b/dali/public-api/adaptor-framework/widget.cpp index bc8d070..7398747 100644 --- a/dali/public-api/adaptor-framework/widget.cpp +++ b/dali/public-api/adaptor-framework/widget.cpp @@ -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) diff --git a/dali/public-api/adaptor-framework/widget.h b/dali/public-api/adaptor-framework/widget.h index 9332298..c00a914 100755 --- a/dali/public-api/adaptor-framework/widget.h +++ b/dali/public-api/adaptor-framework/widget.h @@ -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 */ diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index c073254..8a15192 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -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 ) { diff --git a/dali/public-api/adaptor-framework/window.h b/dali/public-api/adaptor-framework/window.h index 05a86de..8105e5d 100644 --- a/dali/public-api/adaptor-framework/window.h +++ b/dali/public-api/adaptor-framework/window.h @@ -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. diff --git a/dali/public-api/capture/capture.cpp b/dali/public-api/capture/capture.cpp index ca7c098..9d288e8 100644 --- a/dali/public-api/capture/capture.cpp +++ b/dali/public-api/capture/capture.cpp @@ -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 ) { diff --git a/dali/public-api/capture/capture.h b/dali/public-api/capture/capture.h index 73afb16..7113eee 100755 --- a/dali/public-api/capture/capture.h +++ b/dali/public-api/capture/capture.h @@ -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 diff --git a/dali/public-api/watch/watch-application.h b/dali/public-api/watch/watch-application.h index df59ef5..1900593 100755 --- a/dali/public-api/watch/watch-application.h +++ b/dali/public-api/watch/watch-application.h @@ -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.