diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c613f6bcd..fe19d11a9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -218,7 +218,6 @@ set(header_files model/math.h model/names.h model/node-printer.h - model/non-copyable.h model/nstime.h model/object-base.h model/object-factory.h diff --git a/src/core/model/non-copyable.h b/src/core/model/non-copyable.h deleted file mode 100644 index ec9b28e4b..000000000 --- a/src/core/model/non-copyable.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2015 Lawrence Livermore National Laboratory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Peter D. Barnes, Jr. - */ - -#ifndef NS3_NON_COPYABLE_H -#define NS3_NON_COPYABLE_H - -/** - * \file - * \ingroup access - * ns3::NonCopyable declaration. - */ - -/** - * \ingroup core - * \defgroup access NonCopyable and Singleton - * Helpers to make classes non-copyable or singleton. - */ - -namespace ns3 { - -/** - * \ingroup access - * A base class for (non-Singleton) objects which shouldn't be copied. - * - * To prevent copying of your `class ExampleNC` just inherit from NonCopyable: - * \code - * class ExampleNC : private NonCopyable { ... }; - * \endcode - * - * This class prevents each instance of a derived class from being copied. - * If you want only a single global instance of the derived class, - * see Singleton. - * - * \internal - * This is based on `boost::noncopyable`. - */ -class NonCopyable -{ -protected: - /** Constructor. */ - NonCopyable () - {} - /** Destructor. */ - ~NonCopyable () - {} - -private: - /** Copy constructor. Private, so not copyable. */ - NonCopyable (const NonCopyable &); - /** - * Assignment. Private, so not copyable. - * \param [in] other The dummy argument - * \return The unmodified copy. - */ - NonCopyable & operator = (const NonCopyable &other); -}; - -} // namespace ns3 - -#endif /* NS3_NON_COPYABLE_H */ diff --git a/src/core/model/simulation-singleton.h b/src/core/model/simulation-singleton.h index c84803adb..2611ecb03 100644 --- a/src/core/model/simulation-singleton.h +++ b/src/core/model/simulation-singleton.h @@ -43,6 +43,11 @@ template class SimulationSingleton { public: + // Delete default constructor, copy constructor and assignment operator to avoid misuse + SimulationSingleton () = delete; + SimulationSingleton (const SimulationSingleton &) = delete; + SimulationSingleton & operator = (const SimulationSingleton &) = delete; + /** * Get a pointer to the singleton instance. * @@ -68,27 +73,6 @@ private: /** Delete the static instance. */ static void DeleteObject (void); - - /** - * \name %Singleton pattern - * Private constructor, copy and assignment operator. - * - * Note these do not have to be implemented, since they are - * never called. - */ - /**@{*/ - /** Default constructor */ - SimulationSingleton (void); - - /** Copy constructor. */ - SimulationSingleton (const SimulationSingleton &); - /** - * Assignment. - * \returns The Singleton. - */ - SimulationSingleton operator = (const SimulationSingleton &); - /**@}*/ - }; } // namespace ns3 diff --git a/src/core/model/singleton.h b/src/core/model/singleton.h index f6a2654a1..67c80ec6f 100644 --- a/src/core/model/singleton.h +++ b/src/core/model/singleton.h @@ -20,9 +20,6 @@ #ifndef SINGLETON_H #define SINGLETON_H -#include "non-copyable.h" - - /** * \file * \ingroup access @@ -60,9 +57,13 @@ namespace ns3 { * finalizer. */ template -class Singleton : private NonCopyable +class Singleton { public: + // Delete copy constructor and assignment operator to avoid misuse + Singleton (const Singleton &) = delete; + Singleton & operator = (const Singleton &) = delete; + /** * Get a pointer to the singleton instance. * @@ -73,6 +74,16 @@ public: */ static T * Get (void); +protected: + /** Constructor. */ + Singleton () + { + } + + /** Destructor. */ + virtual ~Singleton () + { + } }; } // namespace ns3 diff --git a/src/core/model/test.h b/src/core/model/test.h index e594c6959..69280a99e 100644 --- a/src/core/model/test.h +++ b/src/core/model/test.h @@ -28,7 +28,6 @@ #include #include -#include "non-copyable.h" #include "system-wall-clock-ms.h" /** @@ -991,7 +990,7 @@ class TestRunnerImpl; * * \see sample-test-suite.cc */ -class TestCase : private NonCopyable +class TestCase { public: /** \brief How long the test takes to execute. */ @@ -1007,6 +1006,10 @@ public: */ virtual ~TestCase (); + // Delete copy constructor and assignment operator to avoid misuse + TestCase (const TestCase &) = delete; + TestCase & operator = (const TestCase &) = delete; + /** * \return The name of this test */ @@ -1244,7 +1247,7 @@ public: * \brief A simple way to store test vectors (for stimulus or from responses) */ template -class TestVectors : private NonCopyable +class TestVectors { public: /** @@ -1256,6 +1259,10 @@ public: */ virtual ~TestVectors (); + // Delete copy constructor and assignment operator to avoid misuse + TestVectors (const TestVectors &) = delete; + TestVectors & operator = (const TestVectors &) = delete; + /** * \brief Set the expected length of this vector. * diff --git a/src/core/wscript b/src/core/wscript index ab1f6cafa..de49e0ebb 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -364,7 +364,6 @@ def build(bld): 'model/hash-fnv.h', 'model/hash.h', 'model/valgrind.h', - 'model/non-copyable.h', 'model/build-profile.h', 'model/des-metrics.h', 'model/ascii-file.h',