Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Rule of 5" copy/assign/move declarations #601

Merged
merged 10 commits into from
Nov 14, 2019
31 changes: 25 additions & 6 deletions IlmBase/Iex/IexBaseExc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,37 @@ BaseExc::BaseExc (std::stringstream &s) throw () :
// empty
}

BaseExc::BaseExc (const BaseExc &be) throw()
: _message (be._message),
_stackTrace (be._stackTrace)
{
}

BaseExc::BaseExc (const BaseExc &be) throw () :
_message (be._message),
_stackTrace (be._stackTrace)
BaseExc::~BaseExc () throw ()
{
// empty
}

BaseExc &
BaseExc::operator = (const BaseExc& be) throw ()
{
if (this != &be)
{
_message = be._message;
_stackTrace = be._stackTrace;
}

BaseExc::~BaseExc () throw ()
return *this;
}

BaseExc &
BaseExc::operator = (BaseExc&& be) throw ()
{
// empty
if (this != &be)
{
_message = std::move (be._message);
_stackTrace = std::move (be._stackTrace);
}
return *this;
}

const char *
Expand Down
19 changes: 15 additions & 4 deletions IlmBase/Iex/IexBaseExc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ class BaseExc: public std::exception
// Constructors and destructor
//----------------------------

IEX_EXPORT BaseExc (const char *s = 0) throw(); // std::string (s)
IEX_EXPORT BaseExc (const std::string &s) throw(); // std::string (s)
IEX_EXPORT BaseExc (std::stringstream &s) throw(); // std::string (s.str())
IEX_EXPORT BaseExc (const char *s = nullptr) throw(); // std::string (s)
IEX_EXPORT BaseExc (const std::string &s) throw(); // std::string (s)
IEX_EXPORT BaseExc (std::stringstream &s) throw(); // std::string (s.str())

IEX_EXPORT BaseExc (const BaseExc &be) throw();
IEX_EXPORT BaseExc (BaseExc &&be) throw();
IEX_EXPORT virtual ~BaseExc () throw ();

IEX_EXPORT BaseExc & operator = (const BaseExc& be) throw () = delete;
IEX_EXPORT BaseExc & operator = (const BaseExc& be) throw ();
IEX_EXPORT BaseExc & operator = (BaseExc&& be) throw ();

//---------------------------------------------------
// what() method -- e.what() returns _message.c_str()
Expand Down Expand Up @@ -138,13 +140,22 @@ class BaseExc: public std::exception
exp name (const char* text) throw(); \
exp name (const std::string &text) throw(); \
exp name (std::stringstream &text) throw(); \
exp name (const name &other) throw(); \
exp name (name &&other) throw(); \
exp name& operator = (name &other) throw(); \
exp name& operator = (name &&other) throw(); \
exp ~name() throw(); \
};

#define DEFINE_EXC_EXP_IMPL(exp, name, base) \
exp name::name () throw () : base () {} \
exp name::name (const char* text) throw () : base (text) {} \
exp name::name (const std::string& text) throw () : base (text) {} \
exp name::name (std::stringstream& text) throw () : base (text) {} \
exp name::name (const name &other) throw() : base (other) {} \
exp name::name (name &&other) throw() : base (other) {} \
exp name& name::operator = (name &other) throw() { base::operator=(other); return *this; } \
exp name& name::operator = (name &&other) throw() { base::operator=(other); return *this; } \
exp name::~name () throw () {}

// For backward compatibility.
Expand Down
2 changes: 2 additions & 0 deletions IlmBase/IlmThread/IlmThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class Thread
std::thread _thread;

Thread &operator= (const Thread& t) = delete;
Thread &operator= (Thread&& t) = delete;
Thread (const Thread& t) = delete;
Thread (Thread&& t) = delete;
#endif
};

Expand Down
2 changes: 2 additions & 0 deletions IlmBase/IlmThread/IlmThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct ThreadPool::Data
~Data();
Data (const Data&) = delete;
Data &operator= (const Data&) = delete;
Data (Data&&) = delete;
Data &operator= (Data&&) = delete;

struct SafeProvider
{
Expand Down
5 changes: 5 additions & 0 deletions IlmBase/IlmThread/IlmThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ class ILMTHREAD_EXPORT TaskGroup
TaskGroup();
~TaskGroup();

TaskGroup (const TaskGroup& other) = delete;
TaskGroup& operator = (const TaskGroup& other) = delete;
TaskGroup (TaskGroup&& other) = delete;
TaskGroup& operator = (TaskGroup&& other) = delete;

// marks one task as finished
// should be used by the thread pool provider to notify
// as it finishes tasks
Expand Down
10 changes: 10 additions & 0 deletions OpenEXR/IlmImf/ImfAcesFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class AcesOutputFile::Data
Data();
~Data();

Data (const Data& other) = delete;
Data& operator = (const Data& other) = delete;
Data (Data&& other) = delete;
Data& operator = (Data&& other) = delete;

RgbaOutputFile * rgbaFile;
};

Expand Down Expand Up @@ -338,6 +343,11 @@ class AcesInputFile::Data
Data();
~Data();

Data (const Data& other) = delete;
Data& operator = (const Data& other) = delete;
Data (Data&& other) = delete;
Data& operator = (Data&& other) = delete;

void initColorConversion ();

RgbaInputFile * rgbaFile;
Expand Down
12 changes: 8 additions & 4 deletions OpenEXR/IlmImf/ImfAcesFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ class AcesOutputFile

private:

AcesOutputFile (const AcesOutputFile &); // not implemented
AcesOutputFile & operator = (const AcesOutputFile &); // not implemented
AcesOutputFile (const AcesOutputFile &) = delete;
AcesOutputFile & operator = (const AcesOutputFile &) = delete;
AcesOutputFile (AcesOutputFile &&) = delete;
AcesOutputFile & operator = (AcesOutputFile &&) = delete;

class Data;

Expand Down Expand Up @@ -343,8 +345,10 @@ class AcesInputFile

private:

AcesInputFile (const AcesInputFile &); // not implemented
AcesInputFile & operator = (const AcesInputFile &); // not implemented
AcesInputFile (const AcesInputFile &) = delete;
AcesInputFile & operator = (const AcesInputFile &) = delete;
AcesInputFile (AcesInputFile &&) = delete;
AcesInputFile & operator = (AcesInputFile &&) = delete;

class Data;

Expand Down
12 changes: 8 additions & 4 deletions OpenEXR/IlmImf/ImfArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ class Array

private:

Array (const Array &); // Copying and assignment
Array & operator = (const Array &); // are not implemented
Array (const Array &) = delete;
Array & operator = (const Array &) = delete;
Array (Array &&) = delete;
Array & operator = (Array &&) = delete;

long _size;
T * _data;
Expand Down Expand Up @@ -176,8 +178,10 @@ class Array2D

private:

Array2D (const Array2D &); // Copying and assignment
Array2D & operator = (const Array2D &); // are not implemented
Array2D (const Array2D &) = delete;
Array2D & operator = (const Array2D &) = delete;
Array2D (Array2D &&) = delete;
Array2D & operator = (Array2D &&) = delete;

long _sizeX;
long _sizeY;
Expand Down
42 changes: 11 additions & 31 deletions OpenEXR/IlmImf/ImfAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,21 @@ class TypedAttribute: public Attribute
{
public:

//----------------------------
// Constructors and destructor
//------------_---------------
//------------------------------------------------------------
// Constructors and destructor: default behavior. This assumes
// that the type T is copyable/assignable/moveable.
//------------------------------------------------------------

TypedAttribute ();
TypedAttribute () = default;
TypedAttribute (const T &value);
TypedAttribute (const TypedAttribute<T> &other);
virtual ~TypedAttribute ();
TypedAttribute (const TypedAttribute<T> &other) = default;
TypedAttribute (TypedAttribute<T> &&other) = default;

virtual ~TypedAttribute () = default;

TypedAttribute& operator = (const TypedAttribute<T>& other) = default;
TypedAttribute& operator = (TypedAttribute<T>&& other) = default;

//--------------------------------
// Access to the attribute's value
//--------------------------------
Expand Down Expand Up @@ -244,14 +249,6 @@ class TypedAttribute: public Attribute
//------------------------------------
// Implementation of TypedAttribute<T>
//------------------------------------
template <class T>
TypedAttribute<T>::TypedAttribute ():
Attribute (),
_value (T())
{
// empty
}


template <class T>
TypedAttribute<T>::TypedAttribute (const T & value):
Expand All @@ -261,23 +258,6 @@ TypedAttribute<T>::TypedAttribute (const T & value):
// empty
}


template <class T>
TypedAttribute<T>::TypedAttribute (const TypedAttribute<T> &other):
Attribute (other),
_value ()
{
copyValueFrom (other);
}


template <class T>
TypedAttribute<T>::~TypedAttribute ()
{
// empty
}


template <class T>
inline T &
TypedAttribute<T>::value ()
Expand Down
5 changes: 5 additions & 0 deletions OpenEXR/IlmImf/ImfAutoArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
AutoArray (): _data (new T [size]) { memset(_data, 0, size*sizeof(T)); }
~AutoArray () {delete [] _data;}

AutoArray (const AutoArray& other) = delete;
AutoArray& operator = (const AutoArray& other) = delete;
AutoArray (AutoArray&& other) = delete;
AutoArray& operator = (AutoArray&& other) = delete;

operator T * () {return _data;}
operator const T * () const {return _data;}

Expand Down
5 changes: 5 additions & 0 deletions OpenEXR/IlmImf/ImfB44Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class B44Compressor: public Compressor
IMF_EXPORT
virtual ~B44Compressor ();

B44Compressor (const B44Compressor& other) = delete;
B44Compressor& operator = (const B44Compressor& other) = delete;
B44Compressor (B44Compressor&& other) = delete;
B44Compressor& operator = (B44Compressor&& other) = delete;

IMF_EXPORT
virtual int numScanLines () const;

Expand Down
6 changes: 4 additions & 2 deletions OpenEXR/IlmImf/ImfCompositeDeepScanLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ class CompositeDeepScanLine
private :
struct Data *_Data;

CompositeDeepScanLine(const CompositeDeepScanLine &); // not implemented
const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &); // not implemented
CompositeDeepScanLine(const CompositeDeepScanLine &) = delete;
CompositeDeepScanLine & operator=(const CompositeDeepScanLine &) = delete;
CompositeDeepScanLine(CompositeDeepScanLine &&) = delete;
CompositeDeepScanLine & operator=(CompositeDeepScanLine &&) = delete;
};

OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Expand Down
5 changes: 5 additions & 0 deletions OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ struct DeepScanLineInputFile::Data: public Mutex
Data (int numThreads);
~Data ();

Data (const Data& data) = delete;
Data& operator = (const Data& data) = delete;
Data (Data&& data) = delete;
Data& operator = (Data&& data) = delete;

inline LineBuffer * getLineBuffer (int number); // hash function from line
// buffer indices into our
// vector of line buffers
Expand Down
4 changes: 4 additions & 0 deletions OpenEXR/IlmImf/ImfDeepScanLineInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class DeepScanLineInputFile : public GenericInputFile
int version, /*version field from file*/
int numThreads = globalThreadCount());

DeepScanLineInputFile (const DeepScanLineInputFile& other) = delete;
DeepScanLineInputFile& operator = (const DeepScanLineInputFile& other) = delete;
DeepScanLineInputFile (DeepScanLineInputFile&& other) = delete;
DeepScanLineInputFile& operator = (DeepScanLineInputFile&& other) = delete;

//-----------------------------------------
// Destructor -- deallocates internal data
Expand Down
4 changes: 4 additions & 0 deletions OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ struct DeepScanLineOutputFile::Data
Data (int numThreads);
~Data ();

Data (const Data& other) = delete;
Data& operator = (const Data& other) = delete;
Data (Data&& other) = delete;
Data& operator = (Data&& other) = delete;

inline LineBuffer * getLineBuffer (int number);// hash function from line
// buffer indices into our
Expand Down
6 changes: 4 additions & 2 deletions OpenEXR/IlmImf/ImfDeepScanLineOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ class DeepScanLineOutputFile : public GenericOutputFile
//------------------------------------------------------------
DeepScanLineOutputFile (const OutputPartData* part);

DeepScanLineOutputFile (const DeepScanLineOutputFile &); // not implemented
DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &); // not implemented
DeepScanLineOutputFile (const DeepScanLineOutputFile &) = delete;
DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &) = delete;
DeepScanLineOutputFile (DeepScanLineOutputFile &&) = delete;
DeepScanLineOutputFile & operator = (DeepScanLineOutputFile &&) = delete;

void initialize (const Header &header);
void initializeLineBuffer();
Expand Down
5 changes: 5 additions & 0 deletions OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ struct DeepTiledInputFile::Data: public Mutex
Data (int numThreads);
~Data ();

Data (const Data& other) = delete;
Data& operator = (const Data& other) = delete;
Data (Data&& other) = delete;
Data& operator = (Data&& other) = delete;

inline TileBuffer * getTileBuffer (int number);
// hash function from tile indices
// into our vector of tile buffers
Expand Down
6 changes: 4 additions & 2 deletions OpenEXR/IlmImf/ImfDeepTiledInputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,10 @@ class DeepTiledInputFile : public GenericInputFile

DeepTiledInputFile (InputPartData* part);

DeepTiledInputFile (const DeepTiledInputFile &); // not implemented
DeepTiledInputFile & operator = (const DeepTiledInputFile &); // not implemented
DeepTiledInputFile (const DeepTiledInputFile &) = delete;
DeepTiledInputFile & operator = (const DeepTiledInputFile &) = delete;
DeepTiledInputFile (DeepTiledInputFile &&) = delete;
DeepTiledInputFile & operator = (DeepTiledInputFile &&) = delete;

DeepTiledInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, int version,
int numThreads);
Expand Down
10 changes: 10 additions & 0 deletions OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ struct BufferedTile
delete [] pixelData;
delete [] sampleCountTableData;
}

BufferedTile (const BufferedTile& other) = delete;
BufferedTile& operator = (const BufferedTile& other) = delete;
BufferedTile (BufferedTile&& other) = delete;
BufferedTile& operator = (BufferedTile&& other) = delete;
};


Expand Down Expand Up @@ -311,6 +316,11 @@ struct DeepTiledOutputFile::Data
Data (int numThreads);
~Data ();

Data (const Data& other) = delete;
Data& operator = (const Data& other) = delete;
Data (Data&& other) = delete;
Data& operator = (Data&& other) = delete;

inline TileBuffer * getTileBuffer (int number);
// hash function from tile
// buffer coords into our
Expand Down
Loading