core: Remove NonCopyable class
This commit is contained in:
committed by
Tom Henderson
parent
4ebdc0c6c6
commit
96ec88cd59
@@ -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
|
||||
|
||||
@@ -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. <pdbarnes@llnl.gov>
|
||||
*/
|
||||
|
||||
#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 */
|
||||
@@ -43,6 +43,11 @@ template <typename T>
|
||||
class SimulationSingleton
|
||||
{
|
||||
public:
|
||||
// Delete default constructor, copy constructor and assignment operator to avoid misuse
|
||||
SimulationSingleton<T> () = delete;
|
||||
SimulationSingleton<T> (const SimulationSingleton<T> &) = delete;
|
||||
SimulationSingleton<T> & operator = (const SimulationSingleton<T> &) = 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<T> (void);
|
||||
|
||||
/** Copy constructor. */
|
||||
SimulationSingleton<T> (const SimulationSingleton<T> &);
|
||||
/**
|
||||
* Assignment.
|
||||
* \returns The Singleton.
|
||||
*/
|
||||
SimulationSingleton<T> operator = (const SimulationSingleton<T> &);
|
||||
/**@}*/
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -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 <typename T>
|
||||
class Singleton : private NonCopyable
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
// Delete copy constructor and assignment operator to avoid misuse
|
||||
Singleton<T> (const Singleton<T> &) = delete;
|
||||
Singleton<T> & operator = (const Singleton<T> &) = delete;
|
||||
|
||||
/**
|
||||
* Get a pointer to the singleton instance.
|
||||
*
|
||||
@@ -73,6 +74,16 @@ public:
|
||||
*/
|
||||
static T * Get (void);
|
||||
|
||||
protected:
|
||||
/** Constructor. */
|
||||
Singleton<T> ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~Singleton<T> ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
|
||||
#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 <typename T>
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user