Skip to content

Commit dcbcf64

Browse files
committed
platform: Tag classes DirHandle, FileHandle, FileLike, FileSystemHandle, FileSystemLike, LocalFileHandle, LocalFileSystem and PlatformMutex as non copyable.
This avoid unwanted copy of these type which is a programming error.
1 parent 4f79438 commit dcbcf64

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

platform/DirHandle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <stdint.h>
2020
#include "platform/platform.h"
2121
#include "platform/FileHandle.h"
22+
#include "platform/NonCopyable.h"
2223

2324
namespace mbed {
2425
/** \addtogroup platform */
@@ -41,7 +42,7 @@ namespace mbed {
4142
* @note Synchronization level: Set by subclass
4243
* @ingroup platform
4344
*/
44-
class DirHandle {
45+
class DirHandle : private NonCopyable<DirHandle> {
4546
public:
4647
virtual ~DirHandle() {}
4748

platform/FileHandle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef int FILEHANDLE;
2222
#include "Callback.h"
2323
#include "platform/mbed_poll.h"
2424
#include "platform/platform.h"
25+
#include "platform/NonCopyable.h"
2526

2627
namespace mbed {
2728
/** \addtogroup platform */
@@ -37,7 +38,7 @@ namespace mbed {
3738
* @note Synchronization level: Set by subclass
3839
* @ingroup platform
3940
*/
40-
class FileHandle {
41+
class FileHandle : private NonCopyable<FileHandle> {
4142
public:
4243
virtual ~FileHandle() {}
4344

platform/FileLike.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "platform/mbed_toolchain.h"
2020
#include "platform/FileBase.h"
2121
#include "platform/FileHandle.h"
22+
#include "platform/NonCopyable.h"
2223

2324
namespace mbed {
2425
/** \addtogroup platform */
@@ -31,7 +32,7 @@ namespace mbed {
3132
* @note Synchronization level: Set by subclass
3233
* @ingroup platform
3334
*/
34-
class FileLike : public FileHandle, public FileBase {
35+
class FileLike : public FileHandle, public FileBase, private NonCopyable<FileLike> {
3536
public:
3637
/** Constructor FileLike
3738
*

platform/FileSystemHandle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "platform/FileBase.h"
2222
#include "platform/FileHandle.h"
2323
#include "platform/DirHandle.h"
24+
#include "platform/NonCopyable.h"
2425

2526
namespace mbed {
2627
/** \addtogroup drivers */
@@ -35,7 +36,7 @@ namespace mbed {
3536
*
3637
* @note Synchronization level: Set by subclass
3738
*/
38-
class FileSystemHandle {
39+
class FileSystemHandle : private NonCopyable<FileSystemHandle> {
3940
public:
4041
/** FileSystemHandle lifetime
4142
*/

platform/FileSystemLike.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "platform/FileSystemHandle.h"
2222
#include "platform/FileHandle.h"
2323
#include "platform/DirHandle.h"
24+
#include "platform/NonCopyable.h"
2425

2526
namespace mbed {
2627
/** \addtogroup platform */
@@ -35,7 +36,7 @@ namespace mbed {
3536
* @note Synchronization level: Set by subclass
3637
* @ingroup platform
3738
*/
38-
class FileSystemLike : public FileSystemHandle, public FileBase {
39+
class FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable<FileSystemLike> {
3940
public:
4041
/** FileSystemLike lifetime
4142
*/

platform/LocalFileSystem.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "platform/FileSystemLike.h"
2424
#include "platform/PlatformMutex.h"
25+
#include "platform/NonCopyable.h"
2526

2627
namespace mbed {
2728
/** \addtogroup platform */
@@ -34,7 +35,7 @@ FILEHANDLE local_file_open(const char* name, int flags);
3435
* @class LocalFileHandle
3536
* @ingroup platform
3637
*/
37-
class LocalFileHandle : public FileHandle {
38+
class LocalFileHandle : public FileHandle, private NonCopyable<LocalFileHandle> {
3839

3940
public:
4041
LocalFileHandle(FILEHANDLE fh);
@@ -98,7 +99,7 @@ class LocalFileHandle : public FileHandle {
9899
* not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
99100
* @ingroup platform
100101
*/
101-
class LocalFileSystem : public FileSystemLike {
102+
class LocalFileSystem : public FileSystemLike, private NonCopyable<LocalFileSystem> {
102103
// No modifiable state
103104

104105
public:

platform/PlatformMutex.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
#ifndef PLATFORM_MUTEX_H
1919
#define PLATFORM_MUTEX_H
2020

21+
#include "platform/NonCopyable.h"
22+
2123
#ifdef MBED_CONF_RTOS_PRESENT
2224
#include "rtos/Mutex.h"
2325
typedef rtos::Mutex PlatformMutex;
2426
#else
2527
/** A stub mutex for when an RTOS is not present
2628
* @ingroup platform
2729
*/
28-
class PlatformMutex {
30+
class PlatformMutex : private mbed::NonCopyable<PlatformMutex> {
2931
public:
3032
PlatformMutex() {
3133
// Stub

0 commit comments

Comments
 (0)