Replace noncopyable class to delete keyword 76/82676/3
authorsangwan.kwon <sangwan.kwon@samsung.com>
Fri, 5 Aug 2016 01:56:23 +0000 (10:56 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Fri, 5 Aug 2016 05:16:46 +0000 (14:16 +0900)
[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 <sangwan.kwon@samsung.com>
17 files changed:
tests/CMakeLists.txt
tests/dpl/include/dpl/binary_queue.h
tests/dpl/include/dpl/noncopyable.h [deleted file]
tests/dpl/include/dpl/scoped_resource.h
tests/dpl/include/dpl/test/test_results_collector.h
tests/dpl/include/dpl/test/test_runner_child.h
tests/dpl/src/noncopyable.cpp [deleted file]
vcore/CMakeLists.txt
vcore/dpl/core/include/dpl/noncopyable.h [deleted file]
vcore/dpl/core/src/noncopyable.cpp [deleted file]
vcore/dpl/log/include/dpl/log/log.h
vcore/vcore/CertificateIdentifier.h
vcore/vcore/CertificateLoader.cpp
vcore/vcore/CertificateLoader.h
vcore/vcore/CryptoInit.h
vcore/vcore/ReferenceValidator.h
vcore/vcore/XmlsecAdapter.h

index a49d84e..c0c4c30 100644 (file)
@@ -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
index 66501b8..12019be 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <dpl/abstract_input_output.h>
 #include <dpl/exception.h>
-#include <dpl/noncopyable.h>
 #include <memory>
 #include <list>
 
@@ -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<Bucket *> BucketList;
diff --git a/tests/dpl/include/dpl/noncopyable.h b/tests/dpl/include/dpl/noncopyable.h
deleted file mode 100644 (file)
index 7f951dd..0000000
+++ /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
index 22172f3..882d415 100644 (file)
 #ifndef DPL_SCOPED_RESOURCE_H
 #define DPL_SCOPED_RESOURCE_H
 
-#include <dpl/noncopyable.h>
-
 namespace VcoreDPL {
+
 template<typename ClassPolicy>
-class ScopedResource :
-       private Noncopyable {
+class ScopedResource {
 public:
        typedef typename ClassPolicy::Type ValueType;
        typedef ScopedResource<ClassPolicy> 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
 
index 0140a1e..9656333 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef DPL_TEST_RESULTS_COLLECTOR_H
 #define DPL_TEST_RESULTS_COLLECTOR_H
 
-#include <dpl/noncopyable.h>
 #include <dpl/availability.h>
 #include <vector>
 #include <list>
@@ -37,8 +36,7 @@ class TestResultsCollectorBase;
 typedef std::shared_ptr<TestResultsCollectorBase>
 TestResultsCollectorBasePtr;
 
-class TestResultsCollectorBase :
-       private VcoreDPL::Noncopyable {
+class TestResultsCollectorBase {
 public:
        typedef TestResultsCollectorBase *(*CollectorConstructorFunc)();
        typedef std::list<std::string> 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()
        {
index ab360f2..4627e96 100644 (file)
@@ -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 (file)
index 74fc9af..0000000
+++ /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 <stddef.h>
-#include <dpl/noncopyable.h>
-
-namespace VcoreDPL {
-Noncopyable::Noncopyable()
-{}
-
-Noncopyable::~Noncopyable()
-{}
-} // namespace VcoreDPL
index eeef0d6..7b5dbfb 100644 (file)
@@ -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 (file)
index 7f951dd..0000000
+++ /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 (file)
index 74fc9af..0000000
+++ /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 <stddef.h>
-#include <dpl/noncopyable.h>
-
-namespace VcoreDPL {
-Noncopyable::Noncopyable()
-{}
-
-Noncopyable::~Noncopyable()
-{}
-} // namespace VcoreDPL
index e23c722..07cac3d 100644 (file)
@@ -28,7 +28,6 @@
 #include <string>
 
 #include <dpl/singleton.h>
-#include <dpl/noncopyable.h>
 
 #include <dpl/log/abstract_log_provider.h>
 
@@ -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;
index 6fe9806..adf05c7 100644 (file)
        _WRT_ENGINE_SRC_INSTALLER_CORE_VALIDATION_CORE_CERTIFICATEIDENTIFICATOR_H_
 
 #include <map>
-#include <dpl/noncopyable.h>
 
 #include <vcore/Certificate.h>
 #include <vcore/CertStoreType.h>
 
 namespace ValidationCore {
-class CertificateIdentifier : public VcoreDPL::Noncopyable {
+class CertificateIdentifier {
 public:
        typedef std::map<Certificate::Fingerprint, CertStoreId::Set> 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)
index dd01d41..40c82b1 100644 (file)
@@ -16,7 +16,6 @@
 #include <dpl/assert.h>
 #include <openssl/x509v3.h>
 #include <dpl/log/log.h>
-#include <dpl/noncopyable.h>
 #include <openssl/ecdsa.h>
 #include <openssl/evp.h>
 
index ef42e0b..d87ed7b 100644 (file)
 #include <string>
 #include <string.h>
 
-#include <dpl/noncopyable.h>
 #include <openssl/ssl.h>
 
 #include <vcore/Certificate.h>
 
 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);
 
index 7a2130f..05f8c62 100644 (file)
  */
 #pragma once
 
-#include <dpl/noncopyable.h>
 #include <dpl/singleton.h>
 
 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<CryptoInit> CryptoInitSingleton;
index 2fa025d..450e224 100644 (file)
 #ifndef _VALIDATION_CORE_REFERENCEVALIDATOR_H_
 #define _VALIDATION_CORE_REFERENCEVALIDATOR_H_
 
-#include <dpl/noncopyable.h>
-
 #include <vcore/SignatureData.h>
 
 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);
 
index b03f3c2..0a0a522 100644 (file)
 #include <xmlsec/keysmngr.h>
 
 #include <dpl/exception.h>
-#include <dpl/noncopyable.h>
 #include <dpl/singleton.h>
 
 #include <vcore/Certificate.h>
 #include <vcore/SignatureData.h>
 
 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<std::string> &targetUri);
 
-protected:
-       XmlSec();
-       ~XmlSec();
-
 private:
        enum class ValidateMode : int {
                NORMAL,