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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@
#include "drivers/SerialBase.h"
#include "hal/serial_api.h"
#include "platform/NonCopyable.h"
namespace mbed {
/** \addtogroup drivers */
@ -49,7 +50,7 @@ namespace mbed {
* @endcode
* @ingroup drivers
*/
class RawSerial: public SerialBase {
class RawSerial: public SerialBase, private NonCopyable<RawSerial> {
public:
/** 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 "hal/spi_api.h"
#include "platform/SingletonPtr.h"
#include "platform/NonCopyable.h"
#if DEVICE_SPI_ASYNCH
#include "platform/CThunk.h"
@ -72,7 +73,7 @@ namespace mbed {
* @endcode
* @ingroup drivers
*/
class SPI {
class SPI : private NonCopyable<SPI> {
public:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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