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

@@ -50,17 +50,19 @@ My email address is my screen name followed by @yahoo.com. I'm also known as ben
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "opthelper.h"
#include "noncopyable.h"
//This is for solving big symmetric positive definite linear problems.
float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), float *b, int n, bool OkToModify_b = true, float *x = NULL, float RMSResidual = 0.0f, void *Pass = NULL, int MaximumIterates = 0, void Preconditioner(float *Product, float *x, void *Pass) = NULL);
//Storage and use class for symmetric matrices, the nonzero contents of which are confined to diagonals.
class MultiDiagonalSymmetricMatrix
class MultiDiagonalSymmetricMatrix :
public rtengine::NonCopyable
{
public:
MultiDiagonalSymmetricMatrix(int Dimension, int NumberOfDiagonalsInLowerTriangle);
MultiDiagonalSymmetricMatrix(const MultiDiagonalSymmetricMatrix&) = delete;
~MultiDiagonalSymmetricMatrix();
/* Storage of matrix data, and a function to create memory for Diagonals[index].
@@ -115,11 +117,11 @@ public:
};
class EdgePreservingDecomposition
class EdgePreservingDecomposition :
public rtengine::NonCopyable
{
public:
EdgePreservingDecomposition(int width, int height);
EdgePreservingDecomposition(const EdgePreservingDecomposition&) = delete;
~EdgePreservingDecomposition();
//Create an edge preserving blur of Source. Will create and return, or fill into Blur if not NULL. In place not ok.

View File

@@ -61,13 +61,16 @@
#include <cstring>
#include <cstdint>
#include <cassert>
#ifndef NDEBUG
#include <glibmm.h>
#include <fstream>
#endif
#include "opthelper.h"
#include <assert.h>
#include "rt_math.h"
#include "noncopyable.h"
// Bit representations of flags
enum {
@@ -85,7 +88,8 @@ using LUTd = LUT<double>;
using LUTuc = LUT<uint8_t>;
template<typename T>
class LUT
class LUT :
public rtengine::NonCopyable
{
protected:
// list of variables ordered to improve cache speed
@@ -167,8 +171,6 @@ public:
reset();
}
LUT(const LUT&) = delete;
~LUT()
{
if (owner) {

View File

@@ -66,8 +66,11 @@
#include <cstring>
#include <cstdio>
#include "noncopyable.h"
template<typename T>
class array2D
class array2D :
public rtengine::NonCopyable
{
private:
@@ -167,8 +170,6 @@ public:
}
}
array2D(const array2D&) = delete;
// destructor
~array2D()
{

View File

@@ -20,11 +20,13 @@
#define _CIEIMAGE_H_
#include "image16.h"
#include "noncopyable.h"
namespace rtengine
{
class CieImage
class CieImage :
public NonCopyable
{
private:
bool fromImage;
@@ -41,8 +43,6 @@ public:
float** h_p;
CieImage (int w, int h);
CieImage (const CieImage&) = delete;
~CieImage ();
//Copies image data in Img into this instance.

View File

@@ -7,16 +7,16 @@
#include "cache.h"
#include "alignedbuffer.h"
#include "noncopyable.h"
namespace rtengine
{
class HaldCLUT
class HaldCLUT final :
public NonCopyable
{
public:
HaldCLUT();
HaldCLUT(const HaldCLUT& other) = delete;
HaldCLUT& operator =(const HaldCLUT& other) = delete;
~HaldCLUT();
bool load(const Glib::ustring& filename);
@@ -51,14 +51,12 @@ private:
Glib::ustring clut_profile;
};
class CLUTStore
class CLUTStore final :
public NonCopyable
{
public:
static CLUTStore& getInstance();
CLUTStore(const CLUTStore& other) = delete;
CLUTStore& operator =(const CLUTStore& other) = delete;
std::shared_ptr<HaldCLUT> getClut(const Glib::ustring& filename);
void clearCache();

View File

@@ -22,15 +22,17 @@
#define CPLX_WAVELET_DEC_H_INCLUDED
#include <cstddef>
#include <math.h>
#include <cmath>
#include "cplx_wavelet_level.h"
#include "cplx_wavelet_filter_coeffs.h"
#include "noncopyable.h"
namespace rtengine
{
class wavelet_decomposition
class wavelet_decomposition :
public NonCopyable
{
public:
@@ -58,8 +60,6 @@ public:
template<typename E>
wavelet_decomposition(E * src, int width, int height, int maxlvl, int subsampling, int skipcrop = 1, int numThreads = 1, int Daub4Len = 6);
wavelet_decomposition(const wavelet_decomposition&) = delete;
~wavelet_decomposition();
internal_type ** level_coeffs(int level) const

View File

@@ -26,11 +26,12 @@
#include <glibmm.h>
#include "../rtgui/threadutils.h"
#include "imagefloat.h"
#include "curves.h"
#include "colortemp.h"
#include "../rtgui/threadutils.h"
#include "noncopyable.h"
namespace rtengine
{
@@ -145,14 +146,12 @@ private:
AdobeToneCurve tone_curve;
};
class DCPStore final
class DCPStore final :
public NonCopyable
{
public:
static DCPStore* getInstance();
DCPStore(const DCPStore& other) = delete;
DCPStore& operator =(const DCPStore& other) = delete;
void init(const Glib::ustring& rt_profile_dir);
bool isValidDCPFileName(const Glib::ustring& filename) const;

View File

@@ -17,8 +17,9 @@
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JAGGEDARRAY_H
#define JAGGEDARRAY_H
#pragma once
#include "noncopyable.h"
namespace rtengine
{
@@ -50,7 +51,8 @@ inline void freeJaggedArray (T** const a)
}
template<class T>
class JaggedArray
class JaggedArray :
public NonCopyable
{
public:
JaggedArray (const int W, const int H, const bool initZero = false)
@@ -65,10 +67,6 @@ public:
}
}
JaggedArray (const JaggedArray&) = delete;
JaggedArray& operator= (const JaggedArray&) = delete;
public:
operator T** const () const
{
return a;
@@ -85,5 +83,3 @@ template<class T>
void freeJaggedArray (JaggedArray<T>&);
} // rtengine
#endif // JAGGEDARRAY_H

34
rtengine/noncopyable.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2016 Flössie <floessie.mail@gmail.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
namespace rtengine
{
class NonCopyable
{
public:
NonCopyable() = default;
explicit NonCopyable(const NonCopyable&) = delete;
NonCopyable& operator =(const NonCopyable&) = delete;
};
}

View File

@@ -19,11 +19,13 @@
#ifndef _PROCPARAMS_H_
#define _PROCPARAMS_H_
#include <glibmm.h>
#include <vector>
#include <cstdio>
#include <cmath>
#include <glibmm.h>
#include <lcms2.h>
#include "LUT.h"
#include "coord.h"
@@ -1363,7 +1365,7 @@ class PartialProfile
public:
rtengine::procparams::ProcParams* pparams;
ParamsEdited* pedited;
PartialProfile& operator=(PartialProfile& rhs)
PartialProfile& operator =(const PartialProfile& rhs)
{
pparams = rhs.pparams;
pedited = rhs.pedited;

View File

@@ -20,8 +20,10 @@
#define __RAWIMAGE_H
#include <ctime>
#include "dcraw.h"
#include "imageio.h"
#include "noncopyable.h"
namespace rtengine
{
@@ -32,7 +34,8 @@ struct badPix {
badPix( uint16_t xc, uint16_t yc ): x(xc), y(yc) {}
};
class PixelsMap
class PixelsMap :
public NonCopyable
{
int w; // line width in base_t units
int h; // height
@@ -49,8 +52,6 @@ public:
memset(pm, 0, h * w * base_t_size );
}
PixelsMap(const PixelsMap&) = delete;
~PixelsMap()
{
delete [] pm;

View File

@@ -21,11 +21,13 @@
#include "imagefloat.h"
#include "image16.h"
#include "noncopyable.h"
namespace rtengine
{
class SHMap
class SHMap :
public NonCopyable
{
public:
@@ -33,8 +35,6 @@ public:
float max_f, min_f, avg;
SHMap (int w, int h, bool multiThread);
SHMap(const SHMap&) = delete;
~SHMap ();
void update (Imagefloat* img, double radius, double lumi[3], bool hq, int skip);

View File

@@ -28,7 +28,9 @@
#include <cstdlib>
#include <cmath>
#include <glibmm.h>
#include "../rtengine/procparams.h"
#include "../rtengine/noncopyable.h"
class CacheImageData;
@@ -178,7 +180,8 @@ public:
};
// a class representing a single tag
class Tag
class Tag :
public rtengine::NonCopyable
{
protected:
@@ -202,7 +205,6 @@ public:
Tag (TagDirectory* parent, const TagAttrib* attr, unsigned char *data, TagType t);
Tag (TagDirectory* parent, const TagAttrib* attr, int data, TagType t); // create a new tag from array (used
Tag (TagDirectory* parent, const TagAttrib* attr, const char* data); // create a new tag from array (used
Tag(const Tag&) = delete;
~Tag ();
void initType (unsigned char *data, TagType type);

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.
*