mirror of https://github.com/ARMmbed/mbed-os.git
drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits.
Modified classes are: BusIn, BusOut, BusInOut and InterruptManager.pull/4594/head
parent
f57cc80ecc
commit
7f5b992064
|
@ -19,6 +19,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "drivers/DigitalIn.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -28,7 +29,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Thread safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusIn {
|
||||
class BusIn : private NonCopyable<BusIn> {
|
||||
|
||||
public:
|
||||
/* Group: Configuration Methods */
|
||||
|
@ -115,12 +116,9 @@ protected:
|
|||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
BusIn(const BusIn&);
|
||||
BusIn & operator = (const BusIn&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "drivers/DigitalInOut.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -27,7 +28,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Thread safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusInOut {
|
||||
class BusInOut : private NonCopyable<BusInOut> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -135,11 +136,6 @@ protected:
|
|||
int _nc_mask;
|
||||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
BusInOut(const BusInOut&);
|
||||
BusInOut & operator = (const BusInOut&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "drivers/DigitalOut.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -25,7 +26,7 @@ namespace mbed {
|
|||
/** A digital output bus, used for setting the state of a collection of pins
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusOut {
|
||||
class BusOut : private NonCopyable<BusOut> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -119,11 +120,6 @@ protected:
|
|||
int _nc_mask;
|
||||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
BusOut(const BusOut&);
|
||||
BusOut & operator = (const BusOut&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "cmsis.h"
|
||||
#include "platform/CallChain.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace mbed {
|
||||
|
@ -53,7 +54,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class InterruptManager {
|
||||
class InterruptManager : private NonCopyable<InterruptManager> {
|
||||
public:
|
||||
/** Get the instance of InterruptManager Class
|
||||
*
|
||||
|
@ -138,12 +139,6 @@ private:
|
|||
void lock();
|
||||
void unlock();
|
||||
|
||||
// We declare the copy contructor and the assignment operator, but we don't
|
||||
// implement them. This way, if someone tries to copy/assign our instance,
|
||||
// he will get an error at compile time.
|
||||
InterruptManager(const InterruptManager&);
|
||||
InterruptManager& operator =(const InterruptManager&);
|
||||
|
||||
template<typename T>
|
||||
pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) {
|
||||
_mutex.lock();
|
||||
|
|
Loading…
Reference in New Issue