drivers: Mark non identity types as non copyable with the NonCopyable traits.

Classes changed: CAN, Ethernet, FlashIAP, I2C, InterruptIn, LowPowerTicker, LowPowerTimeout, LowPowerTimer, RawSerial, Serial, SerialBase, SPI, SPISlave, Ticker, Timeout, Timer, TimerEvent and UARTSerial.
pull/4594/head
Vincent Coubard 2017-06-20 14:26:29 +01:00
parent 7f5b992064
commit 3f388ca2a8
18 changed files with 36 additions and 18 deletions

View File

@ -23,6 +23,7 @@
#include "hal/can_api.h" #include "hal/can_api.h"
#include "platform/Callback.h" #include "platform/Callback.h"
#include "platform/PlatformMutex.h" #include "platform/PlatformMutex.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -78,7 +79,7 @@ public:
/** A can bus client, used for communicating with can devices /** A can bus client, used for communicating with can devices
* @ingroup drivers * @ingroup drivers
*/ */
class CAN { class CAN : private NonCopyable<CAN> {
public: public:
/** Creates an CAN interface connected to specific pins. /** Creates an CAN interface connected to specific pins.

View File

@ -17,6 +17,7 @@
#define MBED_ETHERNET_H #define MBED_ETHERNET_H
#include "platform/platform.h" #include "platform/platform.h"
#include "platform/NonCopyable.h"
#if defined (DEVICE_ETHERNET) || defined(DOXYGEN_ONLY) #if defined (DEVICE_ETHERNET) || defined(DOXYGEN_ONLY)
@ -54,7 +55,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class Ethernet { class Ethernet : private NonCopyable<Ethernet> {
public: public:

View File

@ -27,6 +27,7 @@
#include "flash_api.h" #include "flash_api.h"
#include "platform/SingletonPtr.h" #include "platform/SingletonPtr.h"
#include "platform/PlatformMutex.h" #include "platform/PlatformMutex.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
@ -37,7 +38,7 @@ namespace mbed {
* @note Synchronization level: Thread safe * @note Synchronization level: Thread safe
* @ingroup drivers * @ingroup drivers
*/ */
class FlashIAP { class FlashIAP : private NonCopyable<FlashIAP> {
public: public:
FlashIAP(); FlashIAP();
~FlashIAP(); ~FlashIAP();

View File

@ -23,6 +23,7 @@
#include "hal/i2c_api.h" #include "hal/i2c_api.h"
#include "platform/SingletonPtr.h" #include "platform/SingletonPtr.h"
#include "platform/PlatformMutex.h" #include "platform/PlatformMutex.h"
#include "platform/NonCopyable.h"
#if DEVICE_I2C_ASYNCH #if DEVICE_I2C_ASYNCH
#include "platform/CThunk.h" #include "platform/CThunk.h"
@ -53,7 +54,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class I2C { class I2C : private NonCopyable<I2C> {
public: public:
enum RxStatus { enum RxStatus {

View File

@ -25,6 +25,7 @@
#include "platform/Callback.h" #include "platform/Callback.h"
#include "platform/mbed_critical.h" #include "platform/mbed_critical.h"
#include "platform/mbed_toolchain.h" #include "platform/mbed_toolchain.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -56,7 +57,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class InterruptIn { class InterruptIn : private NonCopyable<InterruptIn> {
public: public:

View File

@ -18,6 +18,7 @@
#include "platform/platform.h" #include "platform/platform.h"
#include "drivers/Ticker.h" #include "drivers/Ticker.h"
#include "platform/NonCopyable.h"
#if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY) #if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY)
@ -31,7 +32,7 @@ namespace mbed {
* @note Synchronization level: Interrupt safe * @note Synchronization level: Interrupt safe
* @ingroup drivers * @ingroup drivers
*/ */
class LowPowerTicker : public Ticker { class LowPowerTicker : public Ticker, private NonCopyable<LowPowerTicker> {
public: public:
LowPowerTicker() : Ticker(get_lp_ticker_data()) { LowPowerTicker() : Ticker(get_lp_ticker_data()) {

View File

@ -22,6 +22,7 @@
#include "hal/lp_ticker_api.h" #include "hal/lp_ticker_api.h"
#include "drivers/LowPowerTicker.h" #include "drivers/LowPowerTicker.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -31,7 +32,7 @@ namespace mbed {
* @note Synchronization level: Interrupt safe * @note Synchronization level: Interrupt safe
* @ingroup drivers * @ingroup drivers
*/ */
class LowPowerTimeout : public LowPowerTicker { class LowPowerTimeout : public LowPowerTicker, private NonCopyable<LowPowerTimeout> {
private: private:
virtual void handler(void) { virtual void handler(void) {

View File

@ -18,6 +18,7 @@
#include "platform/platform.h" #include "platform/platform.h"
#include "drivers/Timer.h" #include "drivers/Timer.h"
#include "platform/NonCopyable.h"
#if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY) #if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY)
@ -31,7 +32,7 @@ namespace mbed {
* @note Synchronization level: Interrupt safe * @note Synchronization level: Interrupt safe
* @ingroup drivers * @ingroup drivers
*/ */
class LowPowerTimer : public Timer { class LowPowerTimer : public Timer, private NonCopyable<LowPowerTimer> {
public: public:
LowPowerTimer() : Timer(get_lp_ticker_data()) { LowPowerTimer() : Timer(get_lp_ticker_data()) {

View File

@ -22,6 +22,7 @@
#include "drivers/SerialBase.h" #include "drivers/SerialBase.h"
#include "hal/serial_api.h" #include "hal/serial_api.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -49,7 +50,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class RawSerial: public SerialBase { class RawSerial: public SerialBase, private NonCopyable<RawSerial> {
public: public:
/** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud. /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.

View File

@ -23,6 +23,7 @@
#include "platform/PlatformMutex.h" #include "platform/PlatformMutex.h"
#include "hal/spi_api.h" #include "hal/spi_api.h"
#include "platform/SingletonPtr.h" #include "platform/SingletonPtr.h"
#include "platform/NonCopyable.h"
#if DEVICE_SPI_ASYNCH #if DEVICE_SPI_ASYNCH
#include "platform/CThunk.h" #include "platform/CThunk.h"
@ -72,7 +73,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class SPI { class SPI : private NonCopyable<SPI> {
public: public:

View File

@ -17,6 +17,7 @@
#define MBED_SPISLAVE_H #define MBED_SPISLAVE_H
#include "platform/platform.h" #include "platform/platform.h"
#include "platform/NonCopyable.h"
#if defined (DEVICE_SPISLAVE) || defined(DOXYGEN_ONLY) #if defined (DEVICE_SPISLAVE) || defined(DOXYGEN_ONLY)
@ -52,7 +53,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class SPISlave { class SPISlave : private NonCopyable<SPISlave> {
public: public:

View File

@ -24,6 +24,7 @@
#include "SerialBase.h" #include "SerialBase.h"
#include "PlatformMutex.h" #include "PlatformMutex.h"
#include "serial_api.h" #include "serial_api.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -49,7 +50,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class Serial : public SerialBase, public Stream { class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
public: public:
#if DEVICE_SERIAL_ASYNCH #if DEVICE_SERIAL_ASYNCH

View File

@ -23,6 +23,7 @@
#include "Callback.h" #include "Callback.h"
#include "serial_api.h" #include "serial_api.h"
#include "mbed_toolchain.h" #include "mbed_toolchain.h"
#include "platform/NonCopyable.h"
#if DEVICE_SERIAL_ASYNCH #if DEVICE_SERIAL_ASYNCH
#include "CThunk.h" #include "CThunk.h"
@ -38,7 +39,7 @@ namespace mbed {
* @note Synchronization level: Set by subclass * @note Synchronization level: Set by subclass
* @ingroup drivers * @ingroup drivers
*/ */
class SerialBase { class SerialBase : private NonCopyable<SerialBase> {
public: public:
/** Set the baud rate of the serial port /** Set the baud rate of the serial port

View File

@ -19,6 +19,7 @@
#include "drivers/TimerEvent.h" #include "drivers/TimerEvent.h"
#include "platform/Callback.h" #include "platform/Callback.h"
#include "platform/mbed_toolchain.h" #include "platform/mbed_toolchain.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -59,7 +60,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class Ticker : public TimerEvent { class Ticker : public TimerEvent, private NonCopyable<Ticker> {
public: public:
Ticker() : TimerEvent() { Ticker() : TimerEvent() {

View File

@ -17,6 +17,7 @@
#define MBED_TIMEOUT_H #define MBED_TIMEOUT_H
#include "drivers/Ticker.h" #include "drivers/Ticker.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -52,7 +53,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class Timeout : public Ticker { class Timeout : public Ticker, private NonCopyable<Timeout> {
protected: protected:
virtual void handler(); virtual void handler();

View File

@ -18,6 +18,7 @@
#include "platform/platform.h" #include "platform/platform.h"
#include "hal/ticker_api.h" #include "hal/ticker_api.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -46,7 +47,7 @@ namespace mbed {
* @endcode * @endcode
* @ingroup drivers * @ingroup drivers
*/ */
class Timer { class Timer : private NonCopyable<Timer> {
public: public:
Timer(); Timer();

View File

@ -18,6 +18,7 @@
#include "hal/ticker_api.h" #include "hal/ticker_api.h"
#include "hal/us_ticker_api.h" #include "hal/us_ticker_api.h"
#include "platform/NonCopyable.h"
namespace mbed { namespace mbed {
/** \addtogroup drivers */ /** \addtogroup drivers */
@ -27,7 +28,7 @@ namespace mbed {
* @note Synchronization level: Interrupt safe * @note Synchronization level: Interrupt safe
* @ingroup drivers * @ingroup drivers
*/ */
class TimerEvent { class TimerEvent : private NonCopyable<TimerEvent> {
public: public:
TimerEvent(); TimerEvent();
TimerEvent(const ticker_data_t *data); TimerEvent(const ticker_data_t *data);

View File

@ -27,6 +27,7 @@
#include "PlatformMutex.h" #include "PlatformMutex.h"
#include "serial_api.h" #include "serial_api.h"
#include "CircularBuffer.h" #include "CircularBuffer.h"
#include "platform/NonCopyable.h"
#ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE #ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE
#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 #define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256
@ -38,7 +39,7 @@
namespace mbed { namespace mbed {
class UARTSerial : private SerialBase, public FileHandle { class UARTSerial : private SerialBase, public FileHandle, private NonCopyable<UARTSerial> {
public: public: