mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 06:49:54 +00:00
[instance] disable instance member copying (#4973)
This commit is contained in:
@@ -331,6 +331,7 @@ HEADERS_COMMON = \
|
||||
common/logging.hpp \
|
||||
common/message.hpp \
|
||||
common/new.hpp \
|
||||
common/non_copyable.hpp \
|
||||
common/notifier.hpp \
|
||||
common/random.hpp \
|
||||
common/random_manager.hpp \
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "common/linked_list.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "net/ip6.hpp"
|
||||
#include "net/netif.hpp"
|
||||
@@ -268,7 +269,7 @@ private:
|
||||
* This class implements the CoAP client and server.
|
||||
*
|
||||
*/
|
||||
class CoapBase : public InstanceLocator
|
||||
class CoapBase : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class ResponsesQueue;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_VENDOR_EXTENSION
|
||||
|
||||
@@ -65,7 +66,7 @@ namespace Extension {
|
||||
* Support for vendor extension can be enabled using `OPENTHREAD_ENABLE_VENDOR_EXTENSION` configuration option.
|
||||
*
|
||||
*/
|
||||
class ExtensionBase : public InstanceLocator
|
||||
class ExtensionBase : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <openthread/platform/memory.h>
|
||||
#endif
|
||||
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/random_manager.hpp"
|
||||
#include "common/tasklet.hpp"
|
||||
#include "common/timer.hpp"
|
||||
@@ -119,7 +120,7 @@ namespace ot {
|
||||
* This class contains all the components used by OpenThread.
|
||||
*
|
||||
*/
|
||||
class Instance : public otInstance
|
||||
class Instance : public otInstance, private NonCopyable
|
||||
{
|
||||
public:
|
||||
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "thread/link_quality.hpp"
|
||||
|
||||
@@ -1086,7 +1087,7 @@ private:
|
||||
* This class represents a message pool
|
||||
*
|
||||
*/
|
||||
class MessagePool : public InstanceLocator
|
||||
class MessagePool : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class Message;
|
||||
friend class MessageQueue;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2020, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes a common base class for disabling copying.
|
||||
*/
|
||||
|
||||
#ifndef NON_COPYABLE_HPP_
|
||||
#define NON_COPYABLE_HPP_
|
||||
|
||||
namespace ot {
|
||||
|
||||
/**
|
||||
* This class makes any class that derives from it non-copyable. It is
|
||||
* intended to be used as a private base class.
|
||||
*/
|
||||
class NonCopyable
|
||||
{
|
||||
protected:
|
||||
NonCopyable(void) {}
|
||||
~NonCopyable(void) {}
|
||||
|
||||
private:
|
||||
NonCopyable(const NonCopyable &);
|
||||
NonCopyable &operator=(const NonCopyable &);
|
||||
};
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#endif // NON_COPYABLE_HPP_
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "common/linked_list.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/tasklet.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -73,7 +74,7 @@ namespace ot {
|
||||
* registered at the same time is specified by `OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS` configuration parameter.
|
||||
*
|
||||
*/
|
||||
class Notifier : public InstanceLocator
|
||||
class Notifier : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <mbedtls/entropy.h>
|
||||
#endif
|
||||
|
||||
#include "common/non_copyable.hpp"
|
||||
|
||||
#if (!defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \
|
||||
(!defined(MBEDTLS_NO_PLATFORM_ENTROPY) || defined(MBEDTLS_HAVEGE_C) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT)))
|
||||
#define OT_MBEDTLS_STRONG_DEFAULT_ENTROPY_PRESENT
|
||||
@@ -55,7 +57,7 @@ namespace ot {
|
||||
* This class manages random number generator initialization/deinitialization.
|
||||
*
|
||||
*/
|
||||
class RandomManager
|
||||
class RandomManager : private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "utils/flash.hpp"
|
||||
#if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
|
||||
@@ -50,7 +51,7 @@ namespace MeshCoP {
|
||||
class Dataset;
|
||||
}
|
||||
|
||||
class SettingsDriver : public InstanceLocator
|
||||
class SettingsDriver : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -151,7 +152,7 @@ private:
|
||||
* This class provides structure definitions for different settings keys.
|
||||
*
|
||||
*/
|
||||
class SettingsBase : public InstanceLocator
|
||||
class SettingsBase : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <openthread/tasklet.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
@@ -149,7 +150,7 @@ private:
|
||||
* This class implements the tasklet scheduler.
|
||||
*
|
||||
*/
|
||||
class TaskletScheduler
|
||||
class TaskletScheduler : private NonCopyable
|
||||
{
|
||||
friend class Tasklet;
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "common/debug.hpp"
|
||||
#include "common/linked_list.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/tasklet.hpp"
|
||||
#include "common/time.hpp"
|
||||
|
||||
@@ -251,7 +252,7 @@ private:
|
||||
* This class implements the base timer scheduler.
|
||||
*
|
||||
*/
|
||||
class TimerScheduler : public InstanceLocator
|
||||
class TimerScheduler : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class Timer;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#include "common/non_copyable.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Crypto {
|
||||
|
||||
@@ -52,7 +54,7 @@ namespace Crypto {
|
||||
* This class implements mbedTLS memory.
|
||||
*
|
||||
*/
|
||||
class MbedTls
|
||||
class MbedTls : private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -41,13 +41,14 @@
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace FactoryDiags {
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
class Diags : public InstanceLocator
|
||||
class Diags : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openthread/link_raw.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "mac/sub_mac.hpp"
|
||||
|
||||
@@ -51,7 +52,7 @@ namespace Mac {
|
||||
* This class defines the raw link-layer object.
|
||||
*
|
||||
*/
|
||||
class LinkRaw : public InstanceLocator
|
||||
class LinkRaw : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class ot::Instance;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "net/icmp6.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
@@ -98,7 +99,7 @@ using ot::Encoding::BigEndian::HostSwap32;
|
||||
* This class implements the core IPv6 message processing.
|
||||
*
|
||||
*/
|
||||
class Ip6 : public InstanceLocator
|
||||
class Ip6 : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class ot::Instance;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "common/linked_list.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/tasklet.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
@@ -169,7 +170,7 @@ private:
|
||||
* This class implements an IPv6 network interface.
|
||||
*
|
||||
*/
|
||||
class Netif : public InstanceLocator, public LinkedListEntry<Netif>
|
||||
class Netif : public InstanceLocator, public LinkedListEntry<Netif>, private NonCopyable
|
||||
{
|
||||
friend class Ip6;
|
||||
friend class Address;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
@@ -58,7 +59,7 @@ namespace ot {
|
||||
* This class represents an OpenThread radio abstraction.
|
||||
*
|
||||
*/
|
||||
class Radio : public InstanceLocator
|
||||
class Radio : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class Instance;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
@@ -49,7 +50,7 @@ namespace ot {
|
||||
* This class provides APIs to schedule periodic transmission of MLE Announcement messages for a given number
|
||||
* transmissions per channel.
|
||||
*/
|
||||
class AnnounceSenderBase : public InstanceLocator
|
||||
class AnnounceSenderBase : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
@@ -63,7 +64,7 @@ namespace Utils {
|
||||
* This class implements the Channel Manager.
|
||||
*
|
||||
*/
|
||||
class ChannelManager : public InstanceLocator
|
||||
class ChannelManager : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
enum
|
||||
@@ -295,7 +296,7 @@ private:
|
||||
|
||||
#else // OPENTHREAD_FTD
|
||||
|
||||
class ChannelManager
|
||||
class ChannelManager : private NonCopyable
|
||||
{
|
||||
public:
|
||||
explicit ChannelManager(Instance &) {}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
@@ -70,7 +71,7 @@ namespace Utils {
|
||||
* window (referred to as "channel occupancy").
|
||||
*
|
||||
*/
|
||||
class ChannelMonitor : public InstanceLocator
|
||||
class ChannelMonitor : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
enum
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -175,7 +176,7 @@ private:
|
||||
* +--------------------------------------------------------------------------+
|
||||
*
|
||||
*/
|
||||
class Heap
|
||||
class Heap : private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <openthread/platform/otns.h>
|
||||
|
||||
#include "common/locator.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
@@ -55,7 +56,7 @@ namespace Utils {
|
||||
* This class implements the OTNS Stub that interacts with OTNS.
|
||||
*
|
||||
*/
|
||||
class Otns : public InstanceLocator
|
||||
class Otns : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user