diff --git a/src/sdk/bfs.h b/src/sdk/bfs.h index bfd9c72f..a16f8503 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 : public 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 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 diff --git a/src/sdk/noncopyable.h b/src/sdk/noncopyable.h new file mode 100644 index 00000000..0bccd137 --- /dev/null +++ b/src/sdk/noncopyable.h @@ -0,0 +1,24 @@ +// 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. +// + +#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_