Skip to content

Commit 7f5b992

Browse files
committed
drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits.
Modified classes are: BusIn, BusOut, BusInOut and InterruptManager.
1 parent f57cc80 commit 7f5b992

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

drivers/BusIn.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "platform/platform.h"
2020
#include "drivers/DigitalIn.h"
2121
#include "platform/PlatformMutex.h"
22+
#include "platform/NonCopyable.h"
2223

2324
namespace mbed {
2425
/** \addtogroup drivers */
@@ -28,7 +29,7 @@ namespace mbed {
2829
* @note Synchronization level: Thread safe
2930
* @ingroup drivers
3031
*/
31-
class BusIn {
32+
class BusIn : private NonCopyable<BusIn> {
3233

3334
public:
3435
/* Group: Configuration Methods */
@@ -115,12 +116,9 @@ class BusIn {
115116

116117
PlatformMutex _mutex;
117118

118-
/* disallow copy constructor and assignment operators */
119119
private:
120120
virtual void lock();
121121
virtual void unlock();
122-
BusIn(const BusIn&);
123-
BusIn & operator = (const BusIn&);
124122
};
125123

126124
} // namespace mbed

drivers/BusInOut.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "drivers/DigitalInOut.h"
2020
#include "platform/PlatformMutex.h"
21+
#include "platform/NonCopyable.h"
2122

2223
namespace mbed {
2324
/** \addtogroup drivers */
@@ -27,7 +28,7 @@ namespace mbed {
2728
* @note Synchronization level: Thread safe
2829
* @ingroup drivers
2930
*/
30-
class BusInOut {
31+
class BusInOut : private NonCopyable<BusInOut> {
3132

3233
public:
3334

@@ -135,11 +136,6 @@ class BusInOut {
135136
int _nc_mask;
136137

137138
PlatformMutex _mutex;
138-
139-
/* disallow copy constructor and assignment operators */
140-
private:
141-
BusInOut(const BusInOut&);
142-
BusInOut & operator = (const BusInOut&);
143139
};
144140

145141
} // namespace mbed

drivers/BusOut.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818

1919
#include "drivers/DigitalOut.h"
2020
#include "platform/PlatformMutex.h"
21+
#include "platform/NonCopyable.h"
2122

2223
namespace mbed {
2324
/** \addtogroup drivers */
2425

2526
/** A digital output bus, used for setting the state of a collection of pins
2627
* @ingroup drivers
2728
*/
28-
class BusOut {
29+
class BusOut : private NonCopyable<BusOut> {
2930

3031
public:
3132

@@ -119,11 +120,6 @@ class BusOut {
119120
int _nc_mask;
120121

121122
PlatformMutex _mutex;
122-
123-
/* disallow copy constructor and assignment operators */
124-
private:
125-
BusOut(const BusOut&);
126-
BusOut & operator = (const BusOut&);
127123
};
128124

129125
} // namespace mbed

drivers/InterruptManager.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "cmsis.h"
2020
#include "platform/CallChain.h"
2121
#include "platform/PlatformMutex.h"
22+
#include "platform/NonCopyable.h"
2223
#include <string.h>
2324

2425
namespace mbed {
@@ -53,7 +54,7 @@ namespace mbed {
5354
* @endcode
5455
* @ingroup drivers
5556
*/
56-
class InterruptManager {
57+
class InterruptManager : private NonCopyable<InterruptManager> {
5758
public:
5859
/** Get the instance of InterruptManager Class
5960
*
@@ -138,12 +139,6 @@ class InterruptManager {
138139
void lock();
139140
void unlock();
140141

141-
// We declare the copy contructor and the assignment operator, but we don't
142-
// implement them. This way, if someone tries to copy/assign our instance,
143-
// he will get an error at compile time.
144-
InterruptManager(const InterruptManager&);
145-
InterruptManager& operator =(const InterruptManager&);
146-
147142
template<typename T>
148143
pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) {
149144
_mutex.lock();

0 commit comments

Comments
 (0)