From b30ba30b03724a37c4497483629e226d808e985a Mon Sep 17 00:00:00 2001 From: Zhu Yuejun Date: Fri, 17 Feb 2017 01:14:28 +0800 Subject: [PATCH 1/5] Create noncopyable.h --- src/sdk/noncopyable.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/sdk/noncopyable.h diff --git a/src/sdk/noncopyable.h b/src/sdk/noncopyable.h new file mode 100644 index 00000000..1e0b26c3 --- /dev/null +++ b/src/sdk/noncopyable.h @@ -0,0 +1,24 @@ +// Copyright (c) 2016, Baidu.com, Inc. All Rights Reserved +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef BFS_SDK_NONCOPYABLE_H_ +#define BFS_SDK_NONCOPYABLE_H_ + +namespace baidu { +namespace bfs { + +class noncopyable { +public: + noncopyable() {} + ~noncopyable() {} +private: + noncopyable(const noncopyable&) {} + void operator=(const noncopyable&) {} +}; + +} // namespace bfs +} // namespace baidu + +#endif // BFS_SDK_NONCOPYABLE_H_ From 5d710dc598bb308833b83bb4d3b6e1e35dfed25a Mon Sep 17 00:00:00 2001 From: Zhu Yuejun Date: Fri, 17 Feb 2017 01:22:04 +0800 Subject: [PATCH 2/5] Update bfs.h --- src/sdk/bfs.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/sdk/bfs.h b/src/sdk/bfs.h index bfd9c72f..8e740870 100644 --- a/src/sdk/bfs.h +++ b/src/sdk/bfs.h @@ -13,6 +13,8 @@ #include #include +#include "noncopyable.h" + namespace baidu { namespace bfs { @@ -59,7 +61,7 @@ struct FSOptions { }; /// Bfs File interface -class File { +class File : noncopyable { public: File() {} virtual ~File() {} @@ -71,10 +73,6 @@ class File { virtual int32_t Flush() = 0; virtual int32_t Sync() = 0; virtual int32_t Close() = 0; -private: - // No copying allowed - File(const File&); - void operator=(const File&); }; struct BfsFileInfo { @@ -86,7 +84,7 @@ struct BfsFileInfo { }; // Bfs fileSystem interface -class FS { +class FS : public noncopyable { public: FS() { } virtual ~FS() { } @@ -128,10 +126,6 @@ class FS { std::map >* locations) = 0; virtual int32_t ShutdownChunkServer(const std::vector& cs_address) = 0; virtual int32_t ShutdownChunkServerStat() = 0; -private: - // No copying allowed - FS(const FS&); - void operator=(const FS&); }; } // namespace bfs From 3f4cf775f61ecfd4dd435de934d133807ca10c19 Mon Sep 17 00:00:00 2001 From: Zhu Yuejun Date: Fri, 17 Feb 2017 01:22:53 +0800 Subject: [PATCH 3/5] Update file_impl_wrapper.h --- src/sdk/file_impl_wrapper.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sdk/file_impl_wrapper.h b/src/sdk/file_impl_wrapper.h index ef9ecb9a..62a16c1b 100644 --- a/src/sdk/file_impl_wrapper.h +++ b/src/sdk/file_impl_wrapper.h @@ -34,9 +34,6 @@ class FileImplWrapper : public File { virtual int32_t Close(); private: std::shared_ptr impl_; - // No copying allowed - FileImplWrapper(const FileImplWrapper&); - void operator=(const FileImplWrapper&); }; } // namespace bfs From 8e9e2ff79ba8597a66cb02884d7548ea979eb3bc Mon Sep 17 00:00:00 2001 From: Zhu Yuejun Date: Fri, 17 Feb 2017 01:25:21 +0800 Subject: [PATCH 4/5] Update noncopyable.h --- src/sdk/noncopyable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdk/noncopyable.h b/src/sdk/noncopyable.h index 1e0b26c3..0bccd137 100644 --- a/src/sdk/noncopyable.h +++ b/src/sdk/noncopyable.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, Baidu.com, Inc. All Rights Reserved +// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // From 43517ccb67203eb1c0915c5a508408a86e4af6bc Mon Sep 17 00:00:00 2001 From: Zhu Yuejun Date: Fri, 17 Feb 2017 01:26:24 +0800 Subject: [PATCH 5/5] Update bfs.h --- src/sdk/bfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdk/bfs.h b/src/sdk/bfs.h index 8e740870..a16f8503 100644 --- a/src/sdk/bfs.h +++ b/src/sdk/bfs.h @@ -61,7 +61,7 @@ struct FSOptions { }; /// Bfs File interface -class File : noncopyable { +class File : public noncopyable { public: File() {} virtual ~File() {}