Introduce rtengine/noncopyable.hpp

This commit is contained in:
Flössie
2016-10-08 15:36:44 +02:00
parent 8a2b2e6700
commit d132149a26
20 changed files with 142 additions and 105 deletions

View File

@@ -24,11 +24,14 @@
#include <glibmm/ustring.h>
#include "../rtengine/noncopyable.h"
#include "threadutils.h"
class Thumbnail;
class CacheManager
class CacheManager :
public rtengine::NonCopyable
{
private:
using Entries = std::map<std::string, Thumbnail*>;
@@ -41,12 +44,7 @@ private:
void applyCacheSizeLimitation () const;
CacheManager () = default;
CacheManager (const CacheManager&) = delete;
CacheManager& operator= (const CacheManager&) = delete;
public:
static CacheManager* getInstance ();
void init ();
@@ -69,7 +67,6 @@ public:
const Glib::ustring& fname,
const Glib::ustring& fext,
const Glib::ustring& md5) const;
};
#define cacheMgr CacheManager::getInstance()

View File

@@ -29,7 +29,8 @@
#define DEBUG(format,args...)
//#define DEBUG(format,args...) printf("PreviewLoader::%s: " format "\n", __FUNCTION__, ## args)
class PreviewLoader::Impl
class PreviewLoader::Impl :
public rtengine::NonCopyable
{
public:
struct Job {
@@ -81,8 +82,6 @@ public:
threadPool_ = new Glib::ThreadPool(threadCount, 0);
}
Impl(const Impl&) = delete;
Glib::ThreadPool* threadPool_;
MyMutex mutex_;
JobSet jobs_;

View File

@@ -21,11 +21,17 @@
#include <set>
#include <glibmm.h>
#include "../rtengine/noncopyable.h"
#include "filebrowserentry.h"
class PreviewLoaderListener
{
public:
virtual ~PreviewLoaderListener()
{
}
/**
* @brief a preview is ready
@@ -33,20 +39,22 @@ public:
* @param dir_id directory ID this is for
* @param fd entry
*/
virtual void previewReady (int dir_id, FileBrowserEntry* fd) {}
virtual void previewReady(int dir_id, FileBrowserEntry* fd)
{
}
/**
* @brief all previews have finished loading
*/
virtual void previewsFinished (int dir_id_) {}
virtual void previewsFinished(int dir_id_)
{
}
};
class PreviewLoader
class PreviewLoader :
public rtengine::NonCopyable
{
public:
PreviewLoader(const PreviewLoader&) = delete;
/**
* @brief Singleton entry point.
*

View File

@@ -21,11 +21,14 @@
#include <map>
#include <vector>
#include <glibmm.h>
#include "../rtengine/rtengine.h"
#include "../rtengine/noncopyable.h"
#include "threadutils.h"
#include "paramsedited.h"
#include "guiutils.h"
#include <glibmm.h>
/** @brief This will implement callback functions for the ProfileStore
@@ -118,7 +121,8 @@ public:
* This store can be queried by the GUI to display a Tree of the profiles available
* in the user's and system's profile directory and subdirectories.
*/
class ProfileStore
class ProfileStore :
public rtengine::NonCopyable
{
typedef enum {
@@ -176,9 +180,8 @@ private:
public:
ProfileStore();
ProfileStore (const ProfileStore&) = delete;
~ProfileStore();
bool init ();
void parseProfiles ();
int findFolderId(const Glib::ustring &path);

View File

@@ -27,6 +27,8 @@
#include <glibmm/threads.h>
#include "../rtengine/noncopyable.h"
#if STRICT_MUTEX && NDEBUG
using MyMutexBase = Glib::Threads::Mutex;
#else
@@ -41,15 +43,13 @@ using MyMutexBase = Glib::Threads::RecMutex;
* It will behave like Glib::Threads::RecMutex (STRICT_MUTEX=0) or Glib::Threads::Mutex (STRICT_MUTEX=1).
* Debug builds with strict mutexes, will emit a message and crash immediately upon recursive locking.
*/
class MyMutex : private MyMutexBase
class MyMutex :
public rtengine::NonCopyable,
private MyMutexBase
{
public:
class MyLock;
MyMutex () = default;
MyMutex (const MyMutex&) = delete;
MyMutex& operator= (const MyMutex&) = delete;
void lock ();
bool trylock ();
void unlock ();
@@ -62,7 +62,8 @@ private:
#endif
};
class MyMutex::MyLock
class MyMutex::MyLock :
public rtengine::NonCopyable
{
public:
explicit MyLock (MyMutex& mutex);
@@ -71,9 +72,6 @@ public:
~MyLock ();
MyLock (const MyLock&) = delete;
MyLock& operator= (const MyLock&) = delete;
void acquire ();
bool try_acquire ();
void release ();
@@ -86,13 +84,10 @@ private:
/**
* @brief Custom implementation to replace Glib::Threads::RWLock
*/
class MyRWMutex
class MyRWMutex :
public rtengine::NonCopyable
{
public:
MyRWMutex () = default;
MyRWMutex (const MyRWMutex&) = delete;
MyRWMutex& operator= (const MyRWMutex&) = delete;
friend class MyReaderLock;
friend class MyWriterLock;
@@ -113,14 +108,12 @@ private:
/**
* @brief Custom implementation to replace Glib::Threads::RWLock::ReaderLock
*/
class MyReaderLock
class MyReaderLock :
public rtengine::NonCopyable
{
public:
~MyReaderLock ();
MyReaderLock (const MyReaderLock&) = delete;
MyReaderLock& operator= (const MyReaderLock&) = delete;
#if !TRACE_MYRWMUTEX
explicit MyReaderLock (MyRWMutex& mutex);
@@ -141,14 +134,12 @@ private:
/**
* @brief Custom implementation to replace Glib::Threads::RWLock::WriterLock
*/
class MyWriterLock
class MyWriterLock :
public rtengine::NonCopyable
{
public:
~MyWriterLock ();
MyWriterLock (const MyWriterLock&) = delete;
MyWriterLock& operator= (const MyWriterLock&) = delete;
#if !TRACE_MYRWMUTEX
explicit MyWriterLock (MyRWMutex& mutex);

View File

@@ -30,8 +30,8 @@
#define DEBUG(format,args...)
//#define DEBUG(format,args...) printf("ThumbImageUpdate::%s: " format "\n", __FUNCTION__, ## args)
class
ThumbImageUpdater::Impl
class ThumbImageUpdater::Impl :
public rtengine::NonCopyable
{
public:
@@ -78,8 +78,6 @@ public:
threadPool_ = new Glib::ThreadPool(threadCount, 0);
}
Impl(const Impl&) = delete;
Glib::ThreadPool* threadPool_;
// Need to be a Glib::Threads::Mutex because used in a Glib::Threads::Cond object...

View File

@@ -20,14 +20,19 @@
#define _THUMBIMAGEUPDATER_
#include <glibmm.h>
#include "../rtengine/rtengine.h"
#include "thumbbrowserentrybase.h"
#include <glib.h>
#include "../rtengine/rtengine.h"
#include "../rtengine/noncopyable.h"
#include "thumbbrowserentrybase.h"
class ThumbImageUpdateListener
{
public:
virtual ~ThumbImageUpdateListener()
{
}
/**
* @brief Called when thumbnail image is update
@@ -38,16 +43,15 @@ public:
*
* @note no locks are held when called back
*/
virtual void updateImage (rtengine::IImage8* img, double scale, rtengine::procparams::CropParams cropParams) {}
virtual void updateImage(rtengine::IImage8* img, double scale, rtengine::procparams::CropParams cropParams)
{
}
};
class ThumbImageUpdater
class ThumbImageUpdater :
public rtengine::NonCopyable
{
public:
ThumbImageUpdater(const ThumbImageUpdater&) = delete;
/**
* @brief Singleton entry point.
*