From: Eunki, Hong Date: Thu, 6 Oct 2022 10:49:02 +0000 (+0900) Subject: Minor coverity issue fixes X-Git-Tag: dali_2.2.4~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=a3d1c0e03068de2d010009baac4007bec662ee45 Minor coverity issue fixes Fix some minor coverity issues that might has meanful 1. Implement missing move operation. 2. Remove float equal checks by ==, != operator. 3. Remove useless std::move. 4. Resolve type missed operator (use enum BufferState as bool) 5. Remove virtual operation in Constructor/Destructor. 6. Use referenced iterator so we don't copy value. 7. Remove cyclic header include (a.k.a render-task-list-impl.h -> render-task-impl.h -> render-task-list-impl.h) Change-Id: If01bd4df71f0bc661a9fda10e668204cd35301ad Signed-off-by: Eunki, Hong --- diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedConstStringMap.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedConstStringMap.cpp index 1ee223d..37fba19 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedConstStringMap.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedConstStringMap.cpp @@ -417,3 +417,32 @@ int UtcDaliIndexedConstStringMapStressTest(void) END_TEST; } + +int UtcDaliIndexedConstStringMapMoveTest(void) +{ + IndexedConstStringMap indexedMap; + + std::string expectString = "wahaha"; + + std::string p = expectString; // copy string; + DALI_TEST_CHECK(indexedMap.Register(ConstString("111"), p)); + DALI_TEST_CHECK(!indexedMap.Register(ConstString("111"), p)); + + DALI_TEST_EQUALS(p, expectString, TEST_LOCATION); + DALI_TEST_EQUALS(indexedMap[ConstString("111")], expectString, TEST_LOCATION); + + // Change expect string + expectString = "wehihi"; + p = expectString; + + DALI_TEST_CHECK(indexedMap.Register(ConstString("222"), std::move(p))); + + DALI_TEST_CHECK(p.empty()); // string moved. + DALI_TEST_EQUALS(indexedMap[ConstString("222")], expectString, TEST_LOCATION); + + p = expectString; + + DALI_TEST_CHECK(!indexedMap.Register(ConstString("222"), std::move(p))); + + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedIntegerMap.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedIntegerMap.cpp index a93748f..2863c4c 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedIntegerMap.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-IndexedIntegerMap.cpp @@ -372,3 +372,32 @@ int UtcDaliIndexedIntegerMapStressTest(void) END_TEST; } + +int UtcDaliIndexedIntegerMapMoveTest(void) +{ + IndexedIntegerMap indexedMap; + + std::string expectString = "wahaha"; + + std::string p = expectString; // copy string; + DALI_TEST_CHECK(indexedMap.Register(111, p)); + DALI_TEST_CHECK(!indexedMap.Register(111, p)); + + DALI_TEST_EQUALS(p, expectString, TEST_LOCATION); + DALI_TEST_EQUALS(indexedMap[111], expectString, TEST_LOCATION); + + // Change expect string + expectString = "wehihi"; + p = expectString; + + DALI_TEST_CHECK(indexedMap.Register(222, std::move(p))); + + DALI_TEST_CHECK(p.empty()); // string moved. + DALI_TEST_EQUALS(indexedMap[222], expectString, TEST_LOCATION); + + p = expectString; + + DALI_TEST_CHECK(!indexedMap.Register(222, std::move(p))); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-CameraActor.cpp b/automated-tests/src/dali/utc-Dali-CameraActor.cpp index ce1421e..9f3e6e7 100644 --- a/automated-tests/src/dali/utc-Dali-CameraActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CameraActor.cpp @@ -161,6 +161,41 @@ int UtcDaliCameraActorAssignmentOperatorN(void) END_TEST; } +int UtcDaliCameraActorMoveConstructor(void) +{ + TestApplication application; + + CameraActor actor = CameraActor::New(); + DALI_TEST_CHECK(actor); + + int id = actor.GetProperty(Actor::Property::ID); + + CameraActor moved = std::move(actor); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(id, moved.GetProperty(Actor::Property::ID), TEST_LOCATION); + DALI_TEST_CHECK(!actor); + + END_TEST; +} + +int UtcDaliCameraActorMoveAssignment(void) +{ + TestApplication application; + + CameraActor actor = CameraActor::New(); + DALI_TEST_CHECK(actor); + + int id = actor.GetProperty(Actor::Property::ID); + + CameraActor moved; + moved = std::move(actor); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(id, moved.GetProperty(Actor::Property::ID), TEST_LOCATION); + DALI_TEST_CHECK(!actor); + + END_TEST; +} + int UtcDaliCameraActorNewP(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp index f53121b..5221435 100644 --- a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -73,6 +73,11 @@ int UtcDaliGestureDetectorConstructorP(void) DALI_TEST_PRINT_ASSERT(e); tet_result(TET_FAIL); } + + GestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; } @@ -98,6 +103,12 @@ int UtcDaliGestureDetectorAssignP(void) DALI_TEST_PRINT_ASSERT(e); tet_result(TET_FAIL); } + + GestureDetector moved; + moved = std::move(detector2); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(detector); + DALI_TEST_CHECK(!detector2); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-LocklessBuffer.cpp b/automated-tests/src/dali/utc-Dali-LocklessBuffer.cpp index e649a4e..2358027 100644 --- a/automated-tests/src/dali/utc-Dali-LocklessBuffer.cpp +++ b/automated-tests/src/dali/utc-Dali-LocklessBuffer.cpp @@ -98,6 +98,69 @@ int UtcDaliLocklessBufferMultipleWrites01(void) END_TEST; } +// test one writes, multiple read +int UtcDaliLocklessBufferMultipleWrites02(void) +{ + Integration::LocklessBuffer buf(10); + unsigned char data[10]; + + for(unsigned char i = 0; i < 10; ++i) + { + data[i] = i; + } + + // Write to a buffer + buf.Write(&data[0], 10); + + if(ReadTest(buf, data, 10)) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + // ReadTest one more time. for coverity. + if(ReadTest(buf, data, 10)) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + for(unsigned char i = 0; i < 10; ++i) + { + data[i] = i + 4; + } + + // No reads from buffer, so will overwrite contents of same buffer + buf.Write(&data[0], 10); + + if(ReadTest(buf, data, 10)) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + // ReadTest one more time. for coverity. + if(ReadTest(buf, data, 10)) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + END_TEST; +} + // Simple API test int UtcDaliLocklessBufferGetSize01(void) { diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp index 0909376..3ed67dd 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -150,7 +150,6 @@ int UtcDaliLongPressGestureDetectorCopyConstructorP(void) TestApplication application; LongPressGestureDetector detector = LongPressGestureDetector::New(); - ; LongPressGestureDetector copy(detector); DALI_TEST_CHECK(detector); @@ -163,7 +162,6 @@ int UtcDaliLongPressGestureDetectorAssignmentOperatorP(void) LongPressGestureDetector detector; detector = LongPressGestureDetector::New(); - ; LongPressGestureDetector copy; copy = detector; @@ -173,6 +171,34 @@ int UtcDaliLongPressGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliLongPressGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + DALI_TEST_CHECK(detector); + + LongPressGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliLongPressGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + LongPressGestureDetector detector; + detector = LongPressGestureDetector::New(); + DALI_TEST_CHECK(detector); + + LongPressGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + int UtcDaliLongPressGestureDetectorNew(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp index 5039ef6..a1d4483 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -238,6 +238,34 @@ int UtcDaliPanGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliPanGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + DALI_TEST_CHECK(detector); + + PanGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliPanGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + PanGestureDetector detector; + detector = PanGestureDetector::New(); + DALI_TEST_CHECK(detector); + + PanGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + // Negative test case for a method int UtcDaliPanGestureDetectorNew(void) { diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index 8547f00..2c45979 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -131,7 +131,6 @@ int UtcDaliPinchGestureDetectorCopyConstructorP(void) TestApplication application; PinchGestureDetector detector = PinchGestureDetector::New(); - ; PinchGestureDetector copy(detector); DALI_TEST_CHECK(detector); @@ -143,7 +142,6 @@ int UtcDaliPinchGestureDetectorAssignmentOperatorP(void) TestApplication application; PinchGestureDetector detector = PinchGestureDetector::New(); - ; PinchGestureDetector assign; assign = detector; @@ -153,6 +151,34 @@ int UtcDaliPinchGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliPinchGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + PinchGestureDetector detector = PinchGestureDetector::New(); + DALI_TEST_CHECK(detector); + + PinchGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliPinchGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + PinchGestureDetector detector; + detector = PinchGestureDetector::New(); + DALI_TEST_CHECK(detector); + + PinchGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + int UtcDaliPinchGestureDetectorNew(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp index 65744de..8c1d929 100644 --- a/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-RotationGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -131,7 +131,6 @@ int UtcDaliRotationGestureDetectorCopyConstructorP(void) TestApplication application; RotationGestureDetector detector = RotationGestureDetector::New(); - ; RotationGestureDetector copy(detector); DALI_TEST_CHECK(detector); @@ -143,7 +142,6 @@ int UtcDaliRotationGestureDetectorAssignmentOperatorP(void) TestApplication application; RotationGestureDetector detector = RotationGestureDetector::New(); - ; RotationGestureDetector assign; assign = detector; @@ -153,6 +151,34 @@ int UtcDaliRotationGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliRotationGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + RotationGestureDetector detector = RotationGestureDetector::New(); + DALI_TEST_CHECK(detector); + + RotationGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliRotationGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + RotationGestureDetector detector; + detector = RotationGestureDetector::New(); + DALI_TEST_CHECK(detector); + + RotationGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + int UtcDaliRotationGestureDetectorNew(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index 50c1d8f..4ca3e3a 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -173,7 +173,6 @@ int UtcDaliTapGestureDetectorAssignmentOperatorP(void) TestApplication application; TapGestureDetector detector = TapGestureDetector::New(); - ; TapGestureDetector assign; assign = detector; @@ -183,6 +182,34 @@ int UtcDaliTapGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliRTapGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + DALI_TEST_CHECK(detector); + + TapGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliTapGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + TapGestureDetector detector; + detector = TapGestureDetector::New(); + DALI_TEST_CHECK(detector); + + TapGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + int UtcDaliTapGestureDetectorNew(void) { TestApplication application; diff --git a/dali/devel-api/common/stage.cpp b/dali/devel-api/common/stage.cpp index 1729b5a..f554064 100644 --- a/dali/devel-api/common/stage.cpp +++ b/dali/devel-api/common/stage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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,6 +38,10 @@ Stage::Stage(const Stage& handle) = default; Stage& Stage::operator=(const Stage& rhs) = default; +Stage::Stage(Stage&& handle) = default; + +Stage& Stage::operator=(Stage&& rhs) = default; + Stage::Stage(Internal::Stage* internal) : BaseHandle(internal) { diff --git a/dali/devel-api/common/stage.h b/dali/devel-api/common/stage.h index 32f7bd4..86d17c4 100644 --- a/dali/devel-api/common/stage.h +++ b/dali/devel-api/common/stage.h @@ -2,7 +2,7 @@ #define DALI_STAGE_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -135,6 +135,21 @@ public: */ Stage& operator=(const Stage& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @param[in] handle A reference to the moved handle + */ + Stage(Stage&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + Stage& operator=(Stage&& rhs); + // Containment /** diff --git a/dali/integration-api/lockless-buffer.cpp b/dali/integration-api/lockless-buffer.cpp index 156ba6b..370ddbd 100644 --- a/dali/integration-api/lockless-buffer.cpp +++ b/dali/integration-api/lockless-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -76,7 +76,7 @@ const uint8_t* LocklessBuffer::Read() // This will set mState to 1 if readbuffer 0 was updated, 0 if readbuffer 1 was updated and fail if WRITING is set if(__sync_bool_compare_and_swap(&mState, static_cast(currentWriteBuf | UPDATED), - static_cast(!currentWriteBuf))) + static_cast((currentWriteBuf == R1W0) ? R0W1 : R1W0))) { // swap successful return mBuffer[currentWriteBuf]; @@ -85,7 +85,7 @@ const uint8_t* LocklessBuffer::Read() // UPDATE bit wasn't set or WRITING bit was set in other thread // swap failed, read from current readbuffer - return mBuffer[!currentWriteBuf]; + return mBuffer[(currentWriteBuf == R1W0) ? R0W1 : R1W0]; } uint32_t LocklessBuffer::GetSize() const diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index cce626d..20f85f2 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -47,13 +47,17 @@ Scene::~Scene() = default; Scene::Scene(const Scene& handle) = default; +Scene& Scene::operator=(const Scene& rhs) = default; + +Scene::Scene(Scene&& handle) = default; + +Scene& Scene::operator=(Scene&& rhs) = default; + Scene::Scene(Internal::Scene* internal) : BaseHandle(internal) { } -Scene& Scene::operator=(const Scene& rhs) = default; - void Scene::Add(Actor actor) { GetImplementation(*this).Add(GetImplementation(actor)); diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index bdaf814..aac126f 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -122,6 +122,21 @@ public: Scene& operator=(const Scene& rhs); /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @param [in] handle A reference to the moved handle + */ + Scene(Scene&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @param [in] rhs A reference to the moved handle + * @return A reference to this + */ + Scene& operator=(Scene&& rhs); + + /** * @brief Adds a child Actor to the Scene. * * The child will be referenced. diff --git a/dali/internal/common/indexed-const-string-map.h b/dali/internal/common/indexed-const-string-map.h index 239e7fe..61f1856 100644 --- a/dali/internal/common/indexed-const-string-map.h +++ b/dali/internal/common/indexed-const-string-map.h @@ -109,6 +109,41 @@ public: // Main API } /** + * @brief Register moved element by the ConstString key. + * + * @param[in] key The ConstString key that this container will hold. Duplicated key doesn't allow. + * @param[in] element The element pairwise with key. + * @return True if Register success. Otherwise, return false. + */ + bool Register(const ConstString& key, ElementType&& element) override + { + // Let's make key as compareable type. + const char* comparableKey = key.GetCString(); + + // Find key with binary search. + // We can do binary search cause mCharPtrIndexList is sorted. + const auto& iter = std::lower_bound(mCharPtrIndexList.cbegin(), mCharPtrIndexList.cend(), std::pair(comparableKey, 0u)); + + if(iter == mCharPtrIndexList.cend() || iter->first != comparableKey) + { + // Emplace new element back. + std::uint32_t newElementIndex = mKeyElementPool.size(); + mKeyElementPool.emplace_back(key, std::move(element)); + + // Add new index into mCharPtrIndexList. + mCharPtrIndexList.insert(iter, std::pair(comparableKey, newElementIndex)); + + // Append element as child + return true; + } + else + { + // Else, duplicated key! + return false; + } + } + + /** * @brief Get element by the ConstString key. * * @param[in] key The ConstString key that this container will hold. diff --git a/dali/internal/common/indexed-integer-map.h b/dali/internal/common/indexed-integer-map.h index 57130db..57d957c 100644 --- a/dali/internal/common/indexed-integer-map.h +++ b/dali/internal/common/indexed-integer-map.h @@ -102,6 +102,38 @@ public: // Main API } /** + * @brief Register moved element by the integer key. + * + * @param[in] key The integer key that this container will hold. Duplicated key doesn't allow. + * @param[in] element The element pairwise with key. + * @return True if Register success. Otherwise, return false. + */ + bool Register(const std::uint32_t& key, ElementType&& element) override + { + // Find key with binary search. + // We can do binary search cause mKeyIndexList is sorted. + const auto& iter = std::lower_bound(mKeyIndexList.cbegin(), mKeyIndexList.cend(), std::pair(key, 0u)); + + if(iter == mKeyIndexList.cend() || iter->first != key) + { + // Emplace new element back. + std::uint32_t newElementIndex = mKeyElementPool.size(); + mKeyElementPool.emplace_back(key, std::move(element)); + + // Add new index into mKeyIndexList list. + mKeyIndexList.insert(iter, std::pair(key, newElementIndex)); + + // Append element as child + return true; + } + else + { + // Else, duplicated key! + return false; + } + } + + /** * @brief Get element by the integer key. * * @param[in] key The integer key that this container will hold. diff --git a/dali/internal/common/indexed-map-base.h b/dali/internal/common/indexed-map-base.h index 8f80100..31e3047 100644 --- a/dali/internal/common/indexed-map-base.h +++ b/dali/internal/common/indexed-map-base.h @@ -100,6 +100,15 @@ public: // Virtual API virtual bool Register(const SearchKeyType& key, const ElementType& element) = 0; /** + * @brief Register moved element by the key. + * + * @param[in] key The key that this container will hold. Duplicated key doesn't allow. + * @param[in] element The element pairwise with key. + * @return True if Register success. Otherwise, return false. + */ + virtual bool Register(const SearchKeyType& key, ElementType&& element) = 0; + + /** * @brief Get element by the key. * * @param[in] key The key that this container will hold. @@ -121,7 +130,6 @@ public: */ IndexedMapBase() { - Clear(); } /** @@ -129,7 +137,6 @@ public: */ virtual ~IndexedMapBase() { - mKeyElementPool.clear(); } /** @@ -388,7 +395,7 @@ public: // API for C++11 std style functions. } protected: - std::vector mKeyElementPool; + std::vector mKeyElementPool{}; }; } // namespace Internal diff --git a/dali/internal/event/actors/actor-renderer-container.cpp b/dali/internal/event/actors/actor-renderer-container.cpp index 1083fcb..5e84416 100644 --- a/dali/internal/event/actors/actor-renderer-container.cpp +++ b/dali/internal/event/actors/actor-renderer-container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -74,7 +74,7 @@ RendererPtr RendererContainer::GetRendererAt(uint32_t index) const void RendererContainer::SetBlending(DevelBlendEquation::Type blendEquation) { - for(auto renderer : mRenderers) + for(const auto& renderer : mRenderers) { renderer->SetBlendEquation(static_cast(blendEquation)); } diff --git a/dali/internal/event/common/property-metadata.h b/dali/internal/event/common/property-metadata.h index 539f6d0..9ef14dc 100644 --- a/dali/internal/event/common/property-metadata.h +++ b/dali/internal/event/common/property-metadata.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_PROPERTY_METADATA_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -194,9 +194,9 @@ public: * @note The base animatable property MUST be created before the component animatable property. */ AnimatablePropertyMetadata(Property::Index propertyIndex, - const Property::Value& propertyValue, + Property::Value propertyValue, const SceneGraph::PropertyBase* sceneGraphProperty) - : PropertyMetadata(propertyValue, sceneGraphProperty, true), + : PropertyMetadata(std::move(propertyValue), sceneGraphProperty, true), index(propertyIndex) { DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property"); diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index 7133dce..46d1b48 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -1047,7 +1047,7 @@ void TypeInfo::SetProperty(BaseObject* object, Property::Index index, Property:: } else { - iter->second.setFunc(object, index, std::move(value)); + iter->second.setFunc(object, index, value); } } } @@ -1077,7 +1077,7 @@ void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property } else { - iter->second.setFunc(object, iter->first, std::move(value)); + iter->second.setFunc(object, iter->first, value); } } else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName)) diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 8069b54..9ae9bc7 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index 828156f..b939691 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_RENDER_TASK_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -25,7 +25,6 @@ #include #include -#include #include namespace Dali diff --git a/dali/public-api/actors/camera-actor.cpp b/dali/public-api/actors/camera-actor.cpp index 5222c0d..01fc8e2 100644 --- a/dali/public-api/actors/camera-actor.cpp +++ b/dali/public-api/actors/camera-actor.cpp @@ -53,11 +53,11 @@ CameraActor::~CameraActor() = default; CameraActor::CameraActor(const CameraActor& copy) = default; -CameraActor& CameraActor::operator=(const CameraActor& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +CameraActor& CameraActor::operator=(const CameraActor& rhs) = default; + +CameraActor::CameraActor(CameraActor&& rhs) = default; + +CameraActor& CameraActor::operator=(CameraActor&& rhs) = default; void CameraActor::SetType(Dali::Camera::Type type) { diff --git a/dali/public-api/actors/camera-actor.h b/dali/public-api/actors/camera-actor.h index 754b70e..3f85351 100644 --- a/dali/public-api/actors/camera-actor.h +++ b/dali/public-api/actors/camera-actor.h @@ -190,6 +190,23 @@ public: CameraActor& operator=(const CameraActor& rhs); /** + * @brief Move constructor. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the actor to move + */ + CameraActor(CameraActor&& rhs); + + /** + * @brief Move assignment operator. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the actor to move + * @return A reference to this + */ + CameraActor& operator=(CameraActor&& rhs); + + /** * @brief Sets the camera type. * The default type is Dali::Camera::FREE_LOOK * @SINCE_1_0.0 diff --git a/dali/public-api/actors/layer.cpp b/dali/public-api/actors/layer.cpp index 1f1be7c..31d1729 100644 --- a/dali/public-api/actors/layer.cpp +++ b/dali/public-api/actors/layer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -23,8 +23,6 @@ namespace Dali { -using Dali::Layer; - Layer::Layer() = default; Layer Layer::New() diff --git a/dali/public-api/events/gesture-detector.cpp b/dali/public-api/events/gesture-detector.cpp index 63b3fd1..f59fa01 100644 --- a/dali/public-api/events/gesture-detector.cpp +++ b/dali/public-api/events/gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -39,11 +39,11 @@ GestureDetector::~GestureDetector() = default; GestureDetector::GestureDetector(const GestureDetector& handle) = default; -GestureDetector& GestureDetector::operator=(const GestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +GestureDetector& GestureDetector::operator=(const GestureDetector& rhs) = default; + +GestureDetector::GestureDetector(GestureDetector&& handle) = default; + +GestureDetector& GestureDetector::operator=(GestureDetector&& rhs) = default; void GestureDetector::Attach(Actor actor) { diff --git a/dali/public-api/events/gesture-detector.h b/dali/public-api/events/gesture-detector.h index 9b786f7..5ddcc4d 100644 --- a/dali/public-api/events/gesture-detector.h +++ b/dali/public-api/events/gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_GESTURE_DETECTOR_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -96,6 +96,23 @@ public: // Creation & Destruction */ GestureDetector& operator=(const GestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + GestureDetector(GestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + GestureDetector& operator=(GestureDetector&& rhs); + public: // Actor related /** * @brief Attaches an actor to the gesture. diff --git a/dali/public-api/events/long-press-gesture-detector.cpp b/dali/public-api/events/long-press-gesture-detector.cpp index abc7ee4..a525b71 100644 --- a/dali/public-api/events/long-press-gesture-detector.cpp +++ b/dali/public-api/events/long-press-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -60,11 +60,11 @@ LongPressGestureDetector::~LongPressGestureDetector() = default; LongPressGestureDetector::LongPressGestureDetector(const LongPressGestureDetector& handle) = default; -LongPressGestureDetector& LongPressGestureDetector::operator=(const LongPressGestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +LongPressGestureDetector& LongPressGestureDetector::operator=(const LongPressGestureDetector& rhs) = default; + +LongPressGestureDetector::LongPressGestureDetector(LongPressGestureDetector&& handle) = default; + +LongPressGestureDetector& LongPressGestureDetector::operator=(LongPressGestureDetector&& rhs) = default; void LongPressGestureDetector::SetTouchesRequired(uint32_t touches) { diff --git a/dali/public-api/events/long-press-gesture-detector.h b/dali/public-api/events/long-press-gesture-detector.h index 1520191..472cd4a 100644 --- a/dali/public-api/events/long-press-gesture-detector.h +++ b/dali/public-api/events/long-press-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_LONG_PRESS_GESTURE_DETECTOR_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -143,6 +143,23 @@ public: // Creation & Destruction */ LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + LongPressGestureDetector(LongPressGestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + LongPressGestureDetector& operator=(LongPressGestureDetector&& rhs); + public: // Setters /** * @brief Sets the number of touches required. diff --git a/dali/public-api/events/pan-gesture-detector.cpp b/dali/public-api/events/pan-gesture-detector.cpp index 0300ad4..6bf50c6 100644 --- a/dali/public-api/events/pan-gesture-detector.cpp +++ b/dali/public-api/events/pan-gesture-detector.cpp @@ -54,11 +54,11 @@ PanGestureDetector::~PanGestureDetector() = default; PanGestureDetector::PanGestureDetector(const PanGestureDetector& handle) = default; -PanGestureDetector& PanGestureDetector::operator=(const PanGestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +PanGestureDetector& PanGestureDetector::operator=(const PanGestureDetector& rhs) = default; + +PanGestureDetector::PanGestureDetector(PanGestureDetector&& handle) = default; + +PanGestureDetector& PanGestureDetector::operator=(PanGestureDetector&& rhs) = default; void PanGestureDetector::SetMinimumTouchesRequired(uint32_t minimum) { diff --git a/dali/public-api/events/pan-gesture-detector.h b/dali/public-api/events/pan-gesture-detector.h index 3467ff5..edca424 100644 --- a/dali/public-api/events/pan-gesture-detector.h +++ b/dali/public-api/events/pan-gesture-detector.h @@ -157,6 +157,23 @@ public: // Creation & Destruction */ PanGestureDetector& operator=(const PanGestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + PanGestureDetector(PanGestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + PanGestureDetector& operator=(PanGestureDetector&& rhs); + public: // Setters /** * @brief This is the minimum number of touches required for the pan gesture to be detected. diff --git a/dali/public-api/events/pinch-gesture-detector.cpp b/dali/public-api/events/pinch-gesture-detector.cpp index f2244f6..8d9fa55 100644 --- a/dali/public-api/events/pinch-gesture-detector.cpp +++ b/dali/public-api/events/pinch-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -46,11 +46,11 @@ PinchGestureDetector::~PinchGestureDetector() = default; PinchGestureDetector::PinchGestureDetector(const PinchGestureDetector& handle) = default; -PinchGestureDetector& PinchGestureDetector::operator=(const PinchGestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +PinchGestureDetector& PinchGestureDetector::operator=(const PinchGestureDetector& rhs) = default; + +PinchGestureDetector::PinchGestureDetector(PinchGestureDetector&& handle) = default; + +PinchGestureDetector& PinchGestureDetector::operator=(PinchGestureDetector&& rhs) = default; PinchGestureDetector::DetectedSignalType& PinchGestureDetector::DetectedSignal() { diff --git a/dali/public-api/events/pinch-gesture-detector.h b/dali/public-api/events/pinch-gesture-detector.h index 3a458bf..2b5d63a 100644 --- a/dali/public-api/events/pinch-gesture-detector.h +++ b/dali/public-api/events/pinch-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_PINCH_GESTURE_DETECTOR_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -120,6 +120,23 @@ public: // Creation & Destruction */ PinchGestureDetector& operator=(const PinchGestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + PinchGestureDetector(PinchGestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + PinchGestureDetector& operator=(PinchGestureDetector&& rhs); + public: // Signals /** * @brief This signal is emitted when the pinch gesture is detected on the attached actor. diff --git a/dali/public-api/events/rotation-gesture-detector.cpp b/dali/public-api/events/rotation-gesture-detector.cpp index 0f84368..c62deef 100644 --- a/dali/public-api/events/rotation-gesture-detector.cpp +++ b/dali/public-api/events/rotation-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -46,11 +46,11 @@ RotationGestureDetector::~RotationGestureDetector() = default; RotationGestureDetector::RotationGestureDetector(const RotationGestureDetector& handle) = default; -RotationGestureDetector& RotationGestureDetector::operator=(const RotationGestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +RotationGestureDetector& RotationGestureDetector::operator=(const RotationGestureDetector& rhs) = default; + +RotationGestureDetector::RotationGestureDetector(RotationGestureDetector&& handle) = default; + +RotationGestureDetector& RotationGestureDetector::operator=(RotationGestureDetector&& rhs) = default; RotationGestureDetector::DetectedSignalType& RotationGestureDetector::DetectedSignal() { diff --git a/dali/public-api/events/rotation-gesture-detector.h b/dali/public-api/events/rotation-gesture-detector.h index 185cb19..01c1548 100644 --- a/dali/public-api/events/rotation-gesture-detector.h +++ b/dali/public-api/events/rotation-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_ROTATION_GESTURE_DETECTOR_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -114,6 +114,23 @@ public: // Creation & Destruction */ RotationGestureDetector& operator=(const RotationGestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + RotationGestureDetector(RotationGestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + RotationGestureDetector& operator=(RotationGestureDetector&& rhs); + public: // Signals /** * @brief This signal is emitted when the rotation gesture is detected on the attached actor. diff --git a/dali/public-api/events/tap-gesture-detector.cpp b/dali/public-api/events/tap-gesture-detector.cpp index e491ef0..e45e422 100644 --- a/dali/public-api/events/tap-gesture-detector.cpp +++ b/dali/public-api/events/tap-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -53,11 +53,11 @@ TapGestureDetector::~TapGestureDetector() = default; TapGestureDetector::TapGestureDetector(const TapGestureDetector& handle) = default; -TapGestureDetector& TapGestureDetector::operator=(const TapGestureDetector& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +TapGestureDetector& TapGestureDetector::operator=(const TapGestureDetector& rhs) = default; + +TapGestureDetector::TapGestureDetector(TapGestureDetector&& handle) = default; + +TapGestureDetector& TapGestureDetector::operator=(TapGestureDetector&& rhs) = default; void TapGestureDetector::SetMinimumTapsRequired(uint32_t taps) { diff --git a/dali/public-api/events/tap-gesture-detector.h b/dali/public-api/events/tap-gesture-detector.h index 7782231..2e7392d 100644 --- a/dali/public-api/events/tap-gesture-detector.h +++ b/dali/public-api/events/tap-gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_TAP_GESTURE_DETECTOR_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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,6 +139,23 @@ public: // Creation & Destruction */ TapGestureDetector& operator=(const TapGestureDetector& rhs); + /** + * @brief This move constructor is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] handle A reference to the moved handle + */ + TapGestureDetector(TapGestureDetector&& handle); + + /** + * @brief This move assignment operator is required for (smart) pointer semantics. + * + * @SINCE_2_2.4 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + TapGestureDetector& operator=(TapGestureDetector&& rhs); + public: // Setters /** * @brief Sets the minimum number of taps required. diff --git a/dali/public-api/object/type-registry.cpp b/dali/public-api/object/type-registry.cpp index 93e0d0e..31d7ad3 100644 --- a/dali/public-api/object/type-registry.cpp +++ b/dali/public-api/object/type-registry.cpp @@ -154,7 +154,7 @@ ChildPropertyRegistration::ChildPropertyRegistration(std::string registered, std { DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterChildProperty(std::move(registered), std::move(name), index, type); + Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type); } } // namespace Dali