[niepce] Use NON_COPYABLE() macro when appropriate. Update code style.
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Use NON_COPYABLE() macro when appropriate. Update code style.
- Date: Thu, 1 Jun 2017 03:40:09 +0000 (UTC)
commit 2cb3d62a301c59d12071660ecaf7791e682504cd
Author: Hubert Figuière <hub figuiere net>
Date: Mon May 22 12:04:20 2017 -0400
Use NON_COPYABLE() macro when appropriate. Update code style.
doc/style-guide | 6 ++++++
src/engine/importer/importedfile.hpp | 9 ++++-----
src/libraryclient/libraryclient.hpp | 8 ++++----
3 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/doc/style-guide b/doc/style-guide
index cfba88c..2f4f1c6 100644
--- a/doc/style-guide
+++ b/doc/style-guide
@@ -64,3 +64,9 @@ Use auto when possible.
Avoid raw pointers. Use unique_ptr<> or shared_ptr<>. You can typedef
the pointer type by suffixing Ptr to the class name.
+
+If you want an object non-copyable, use the macro
+```NON_COPYABLE(ClassName)``` in the class definition. Macro defined
+in ```fwk/base/util.hpp```. This will delete the default copy
+constructor and assignment operator. You may have to reimplement the
+default constructor. You can just use ```= default```.
\ No newline at end of file
diff --git a/src/engine/importer/importedfile.hpp b/src/engine/importer/importedfile.hpp
index b79bf48..af3c2fb 100644
--- a/src/engine/importer/importedfile.hpp
+++ b/src/engine/importer/importedfile.hpp
@@ -22,15 +22,14 @@
#include <memory>
#include <string>
+#include "fwk/base/util.hpp"
+
namespace eng {
class ImportedFile {
public:
- ImportedFile()
- {}
-
- ImportedFile(const ImportedFile&) = delete;
- ImportedFile& operator=(const ImportedFile&) = delete;
+ NON_COPYABLE(ImportedFile);
+ ImportedFile() = default;
virtual ~ImportedFile()
{}
diff --git a/src/libraryclient/libraryclient.hpp b/src/libraryclient/libraryclient.hpp
index 321ea32..5f449ef 100644
--- a/src/libraryclient/libraryclient.hpp
+++ b/src/libraryclient/libraryclient.hpp
@@ -24,6 +24,7 @@
#include <memory>
#include "fwk/base/propertybag.hpp"
+#include "fwk/base/util.hpp"
#include "engine/library/clienttypes.hpp"
#include "engine/library/thumbnailcache.hpp"
#include "engine/db/librarytypes.hpp"
@@ -44,7 +45,7 @@ class LibraryClient
: public eng::Storage
{
public:
-
+ NON_COPYABLE(LibraryClient);
LibraryClient(const fwk::Moniker & moniker, const fwk::NotificationCenter::Ptr & nc);
virtual ~LibraryClient();
// @return false in case of error.
@@ -117,9 +118,6 @@ private:
eng::ThumbnailCache m_thumbnailCache;
std::unique_ptr<UIDataProvider> m_uidataprovider;
eng::library_id_t m_trash_id;
-
- LibraryClient(const LibraryClient &) = delete;
- LibraryClient & operator=(const LibraryClient &) = delete;
};
typedef std::shared_ptr<LibraryClient> LibraryClientPtr;
@@ -132,6 +130,8 @@ typedef std::shared_ptr<LibraryClient> LibraryClientPtr;
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0))
+ c-basic-offset:4
+ tab-width:4
indent-tabs-mode:nil
fill-column:80
End:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]