From 59cbdedd8df2c593edafdee2a202e0ad4a67e9cb Mon Sep 17 00:00:00 2001 From: "sangwan.kwon" Date: Fri, 5 Aug 2016 10:56:23 +0900 Subject: [PATCH] Replace noncopyable class to delete keyword [AS-IS] * Noncopyable class still technically allow to copy by members and friends. [TO-BE] * Replace to delete keyword on C++11 Change-Id: I987996d86ba2f05dae7352acf505fc8db292e955 Signed-off-by: sangwan.kwon --- tests/CMakeLists.txt | 1 - tests/dpl/include/dpl/binary_queue.h | 9 ++++-- tests/dpl/include/dpl/noncopyable.h | 37 ---------------------- tests/dpl/include/dpl/scoped_resource.h | 20 ++++++------ .../dpl/include/dpl/test/test_results_collector.h | 12 ++++--- tests/dpl/include/dpl/test/test_runner_child.h | 9 ++++-- tests/dpl/src/noncopyable.cpp | 31 ------------------ vcore/CMakeLists.txt | 1 - vcore/dpl/core/include/dpl/noncopyable.h | 37 ---------------------- vcore/dpl/core/src/noncopyable.cpp | 31 ------------------ vcore/dpl/log/include/dpl/log/log.h | 8 +++-- vcore/vcore/CertificateIdentifier.h | 16 +++++----- vcore/vcore/CertificateLoader.cpp | 1 - vcore/vcore/CertificateLoader.h | 23 ++++++-------- vcore/vcore/CryptoInit.h | 8 +++-- vcore/vcore/ReferenceValidator.h | 10 +++--- vcore/vcore/XmlsecAdapter.h | 16 ++++++---- 17 files changed, 78 insertions(+), 192 deletions(-) delete mode 100644 tests/dpl/include/dpl/noncopyable.h delete mode 100644 tests/dpl/src/noncopyable.cpp delete mode 100644 vcore/dpl/core/include/dpl/noncopyable.h delete mode 100644 vcore/dpl/core/src/noncopyable.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a49d84e..c0c4c30 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,7 +32,6 @@ SET(DPL_TEST_SOURCES ${TEST_DIR}/dpl/src/colors.cpp ${TEST_DIR}/dpl/src/errno_string.cpp ${TEST_DIR}/dpl/src/exception.cpp - ${TEST_DIR}/dpl/src/noncopyable.cpp ${TEST_DIR}/dpl/src/singleton.cpp ${TEST_DIR}/dpl/src/test_results_collector.cpp ${TEST_DIR}/dpl/src/test_runner.cpp diff --git a/tests/dpl/include/dpl/binary_queue.h b/tests/dpl/include/dpl/binary_queue.h index 66501b8..12019be 100644 --- a/tests/dpl/include/dpl/binary_queue.h +++ b/tests/dpl/include/dpl/binary_queue.h @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -67,8 +66,7 @@ public: }; private: - struct Bucket : - private Noncopyable { + struct Bucket { const void *buffer; const void *ptr; size_t size; @@ -82,6 +80,11 @@ private: BufferDeleter deleter, void *userParam); virtual ~Bucket(); + + Bucket(const Bucket &) = delete; + Bucket &operator=(const Bucket &) = delete; + Bucket(Bucket &&) = delete; + Bucket &operator=(const Bucket &&) = delete; }; typedef std::list BucketList; diff --git a/tests/dpl/include/dpl/noncopyable.h b/tests/dpl/include/dpl/noncopyable.h deleted file mode 100644 index 7f951dd..0000000 --- a/tests/dpl/include/dpl/noncopyable.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file noncopyable - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of noncopyable - */ -#ifndef DPL_NONCOPYABLE_H -#define DPL_NONCOPYABLE_H - -namespace VcoreDPL { -class Noncopyable { -private: - Noncopyable(const Noncopyable &); - const Noncopyable &operator=(const Noncopyable &); - -public: - Noncopyable(); - virtual ~Noncopyable(); -}; -} // namespace VcoreDPL - -#endif // DPL_NONCOPYABLE_H diff --git a/tests/dpl/include/dpl/scoped_resource.h b/tests/dpl/include/dpl/scoped_resource.h index 22172f3..882d415 100644 --- a/tests/dpl/include/dpl/scoped_resource.h +++ b/tests/dpl/include/dpl/scoped_resource.h @@ -22,27 +22,25 @@ #ifndef DPL_SCOPED_RESOURCE_H #define DPL_SCOPED_RESOURCE_H -#include - namespace VcoreDPL { + template -class ScopedResource : - private Noncopyable { +class ScopedResource { public: typedef typename ClassPolicy::Type ValueType; typedef ScopedResource ThisType; -protected: - ValueType m_value; - -public: explicit ScopedResource(ValueType value) : m_value(value) { } - ~ScopedResource() { ClassPolicy::Destroy(m_value); } + ScopedResource(const ScopedResource &) = delete; + ScopedResource &operator=(const ScopedResource &) = delete; + ScopedResource(ScopedResource &&) = delete; + ScopedResource &operator=(ScopedResource &&) = delete; + ValueType Get() const { return m_value; @@ -73,6 +71,10 @@ public: { return m_value == ClassPolicy::NullValue(); } + +protected: + ValueType m_value; + }; } // namespace VcoreDPL diff --git a/tests/dpl/include/dpl/test/test_results_collector.h b/tests/dpl/include/dpl/test/test_results_collector.h index 0140a1e..9656333 100644 --- a/tests/dpl/include/dpl/test/test_results_collector.h +++ b/tests/dpl/include/dpl/test/test_results_collector.h @@ -23,7 +23,6 @@ #ifndef DPL_TEST_RESULTS_COLLECTOR_H #define DPL_TEST_RESULTS_COLLECTOR_H -#include #include #include #include @@ -37,8 +36,7 @@ class TestResultsCollectorBase; typedef std::shared_ptr TestResultsCollectorBasePtr; -class TestResultsCollectorBase : - private VcoreDPL::Noncopyable { +class TestResultsCollectorBase { public: typedef TestResultsCollectorBase *(*CollectorConstructorFunc)(); typedef std::list TestCaseIdList; @@ -51,7 +49,13 @@ public: }; }; - virtual ~TestResultsCollectorBase() {} + TestResultsCollectorBase() = default; + virtual ~TestResultsCollectorBase() = default; + + TestResultsCollectorBase(const TestResultsCollectorBase &) = delete; + TestResultsCollectorBase &operator=(const TestResultsCollectorBase &) = delete; + TestResultsCollectorBase(TestResultsCollectorBase &&) = delete; + TestResultsCollectorBase &operator=(TestResultsCollectorBase &&) = delete; virtual bool Configure() { diff --git a/tests/dpl/include/dpl/test/test_runner_child.h b/tests/dpl/include/dpl/test/test_runner_child.h index ab360f2..4627e96 100644 --- a/tests/dpl/include/dpl/test/test_runner_child.h +++ b/tests/dpl/include/dpl/test/test_runner_child.h @@ -27,7 +27,7 @@ namespace VcoreDPL { namespace Test { -class PipeWrapper : VcoreDPL::Noncopyable { +class PipeWrapper { public: enum Usage { READONLY, @@ -41,12 +41,17 @@ public: }; PipeWrapper(); + virtual ~PipeWrapper(); + + PipeWrapper (const PipeWrapper &) = delete; + PipeWrapper &operator=(const PipeWrapper &) = delete; + PipeWrapper (PipeWrapper &&) = delete; + PipeWrapper &operator=(PipeWrapper &&) = delete; bool isReady(); void setUsage(Usage usage); - virtual ~PipeWrapper(); Status send(int code, std::string &message); diff --git a/tests/dpl/src/noncopyable.cpp b/tests/dpl/src/noncopyable.cpp deleted file mode 100644 index 74fc9af..0000000 --- a/tests/dpl/src/noncopyable.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file noncopyable.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of noncopyable - */ -#include -#include - -namespace VcoreDPL { -Noncopyable::Noncopyable() -{} - -Noncopyable::~Noncopyable() -{} -} // namespace VcoreDPL diff --git a/vcore/CMakeLists.txt b/vcore/CMakeLists.txt index eeef0d6..7b5dbfb 100644 --- a/vcore/CMakeLists.txt +++ b/vcore/CMakeLists.txt @@ -22,7 +22,6 @@ SET(VCORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) SET(VCORE_SOURCES ${VCORE_DIR}/dpl/core/src/assert.cpp ${VCORE_DIR}/dpl/core/src/exception.cpp - ${VCORE_DIR}/dpl/core/src/noncopyable.cpp ${VCORE_DIR}/dpl/core/src/singleton.cpp ${VCORE_DIR}/dpl/core/src/colors.cpp diff --git a/vcore/dpl/core/include/dpl/noncopyable.h b/vcore/dpl/core/include/dpl/noncopyable.h deleted file mode 100644 index 7f951dd..0000000 --- a/vcore/dpl/core/include/dpl/noncopyable.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file noncopyable - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of noncopyable - */ -#ifndef DPL_NONCOPYABLE_H -#define DPL_NONCOPYABLE_H - -namespace VcoreDPL { -class Noncopyable { -private: - Noncopyable(const Noncopyable &); - const Noncopyable &operator=(const Noncopyable &); - -public: - Noncopyable(); - virtual ~Noncopyable(); -}; -} // namespace VcoreDPL - -#endif // DPL_NONCOPYABLE_H diff --git a/vcore/dpl/core/src/noncopyable.cpp b/vcore/dpl/core/src/noncopyable.cpp deleted file mode 100644 index 74fc9af..0000000 --- a/vcore/dpl/core/src/noncopyable.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file noncopyable.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of noncopyable - */ -#include -#include - -namespace VcoreDPL { -Noncopyable::Noncopyable() -{} - -Noncopyable::~Noncopyable() -{} -} // namespace VcoreDPL diff --git a/vcore/dpl/log/include/dpl/log/log.h b/vcore/dpl/log/include/dpl/log/log.h index e23c722..07cac3d 100644 --- a/vcore/dpl/log/include/dpl/log/log.h +++ b/vcore/dpl/log/include/dpl/log/log.h @@ -28,7 +28,6 @@ #include #include -#include #include @@ -40,11 +39,16 @@ namespace Log { * To switch logs into old style, export * DPL_USE_OLD_STYLE_LOGS before application start */ -class LogSystem : private Noncopyable { +class LogSystem { public: LogSystem(); virtual ~LogSystem(); + LogSystem(const LogSystem &) = delete; + LogSystem &operator=(const LogSystem &) = delete; + LogSystem(LogSystem &&) = delete; + LogSystem &operator=(LogSystem &&) = delete; + AbstractLogProvider::LogLevel GetLogLevel() const { return m_level; diff --git a/vcore/vcore/CertificateIdentifier.h b/vcore/vcore/CertificateIdentifier.h index 6fe9806..adf05c7 100644 --- a/vcore/vcore/CertificateIdentifier.h +++ b/vcore/vcore/CertificateIdentifier.h @@ -25,22 +25,22 @@ _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATEIDENTIFICATOR_H_ #include -#include #include #include namespace ValidationCore { -class CertificateIdentifier : public VcoreDPL::Noncopyable { +class CertificateIdentifier { public: typedef std::map FingerPrintMap; - CertificateIdentifier() - { - } - ~CertificateIdentifier() - { - } + CertificateIdentifier() = default; + ~CertificateIdentifier() = default; + + CertificateIdentifier(const CertificateIdentifier &) = delete; + CertificateIdentifier &operator=(const CertificateIdentifier &) = delete; + CertificateIdentifier(CertificateIdentifier &&) = delete; + CertificateIdentifier &operator=(CertificateIdentifier &&) = delete; void add(const Certificate::Fingerprint &fingerprint, CertStoreId::Type domain) diff --git a/vcore/vcore/CertificateLoader.cpp b/vcore/vcore/CertificateLoader.cpp index dd01d41..40c82b1 100644 --- a/vcore/vcore/CertificateLoader.cpp +++ b/vcore/vcore/CertificateLoader.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/vcore/vcore/CertificateLoader.h b/vcore/vcore/CertificateLoader.h index ef42e0b..d87ed7b 100644 --- a/vcore/vcore/CertificateLoader.h +++ b/vcore/vcore/CertificateLoader.h @@ -19,20 +19,25 @@ #include #include -#include #include #include namespace ValidationCore { -class CertificateLoader : public VcoreDPL::Noncopyable { +class CertificateLoader { public: + CertificateLoader() = default; + virtual ~CertificateLoader() = default; + + CertificateLoader(const CertificateLoader &) = delete; + CertificateLoader &operator=(const CertificateLoader &) = delete; + CertificateLoader(CertificateLoader &&) = delete; + CertificateLoader &operator=(CertificateLoader &&) = delete; + class CertificateLoaderComparator { public: virtual bool compare(X509 *x509cert) = 0; - virtual ~CertificateLoaderComparator() - { - } + virtual ~CertificateLoaderComparator() = default; }; enum CertificateLoaderResult { @@ -44,14 +49,6 @@ public: UNKNOWN_ERROR }; - CertificateLoader() - { - } - - virtual ~CertificateLoader() - { - } - CertificateLoaderResult loadCertificate(const std::string &storage, CertificateLoaderComparator *cmp); diff --git a/vcore/vcore/CryptoInit.h b/vcore/vcore/CryptoInit.h index 7a2130f..05f8c62 100644 --- a/vcore/vcore/CryptoInit.h +++ b/vcore/vcore/CryptoInit.h @@ -21,15 +21,19 @@ */ #pragma once -#include #include namespace ValidationCore { -class CryptoInit : public VcoreDPL::Noncopyable { +class CryptoInit { public: CryptoInit(); virtual ~CryptoInit(); + + CryptoInit(const CryptoInit &) = delete; + CryptoInit &operator=(const CryptoInit &) = delete; + CryptoInit(CryptoInit &&) = delete; + CryptoInit &operator=(CryptoInit &&) = delete; }; typedef VcoreDPL::Singleton CryptoInitSingleton; diff --git a/vcore/vcore/ReferenceValidator.h b/vcore/vcore/ReferenceValidator.h index 2fa025d..450e224 100644 --- a/vcore/vcore/ReferenceValidator.h +++ b/vcore/vcore/ReferenceValidator.h @@ -23,13 +23,11 @@ #ifndef _VALIDATION_CORE_REFERENCEVALIDATOR_H_ #define _VALIDATION_CORE_REFERENCEVALIDATOR_H_ -#include - #include namespace ValidationCore { -class ReferenceValidator : VcoreDPL::Noncopyable { +class ReferenceValidator { public: enum Result { NO_ERROR = 0, @@ -44,9 +42,13 @@ public: }; ReferenceValidator(const std::string &dirpath); - virtual ~ReferenceValidator(); + ReferenceValidator(const ReferenceValidator &) = delete; + ReferenceValidator &operator=(const ReferenceValidator &) = delete; + ReferenceValidator(ReferenceValidator &&) = delete; + ReferenceValidator &operator=(ReferenceValidator &&) = delete; + Result checkReferences(const SignatureData &signatureData); Result checkOutbound(const std::string &linkPath, const std::string &appPath); diff --git a/vcore/vcore/XmlsecAdapter.h b/vcore/vcore/XmlsecAdapter.h index b03f3c2..0a0a522 100644 --- a/vcore/vcore/XmlsecAdapter.h +++ b/vcore/vcore/XmlsecAdapter.h @@ -27,15 +27,23 @@ #include #include -#include #include #include #include namespace ValidationCore { -class XmlSec : public VcoreDPL::Noncopyable { +class XmlSec { + public: + XmlSec(); + virtual ~XmlSec(); + + XmlSec(const XmlSec &) = delete; + XmlSec &operator=(const XmlSec &) = delete; + XmlSec(XmlSec &&) = delete; + XmlSec &operator=(XmlSec &&) = delete; + struct XmlSecContext { /* You _must_ set one of the value: certificatePath or certificate. */ XmlSecContext() @@ -98,10 +106,6 @@ public: void validateNoHash(XmlSecContext &context); void validatePartialHash(XmlSecContext &context, const std::list &targetUri); -protected: - XmlSec(); - ~XmlSec(); - private: enum class ValidateMode : int { NORMAL, -- 2.7.4