From: Mikko Rasa Date: Sun, 20 Aug 2023 20:51:25 +0000 (+0300) Subject: Make sure classes follow the rule of 0/3/5 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6d9570c97584758e3cfcac6827d439b7fb844cf4;p=libs%2Fgltk.git Make sure classes follow the rule of 0/3/5 --- diff --git a/source/arrangement.h b/source/arrangement.h index 15fb47c..4a651ba 100644 --- a/source/arrangement.h +++ b/source/arrangement.h @@ -3,6 +3,7 @@ #include #include +#include #include "layout.h" #include "mspgltk_api.h" @@ -17,7 +18,7 @@ public: arrangement_error(const std::string &w): std::logic_error(w) { } }; -class MSPGLTK_API Arrangement +class MSPGLTK_API Arrangement: public NonCopyable { protected: enum Side diff --git a/source/partcache.cpp b/source/partcache.cpp index f4c085e..77b51d2 100644 --- a/source/partcache.cpp +++ b/source/partcache.cpp @@ -6,6 +6,24 @@ using namespace std; namespace Msp { namespace GLtk { +CachedPart::CachedPart(CachedPart &&other): + part(other.part), + texture(other.texture), + mesh(other.mesh) +{ + other.mesh = nullptr; +} + +CachedPart &CachedPart::operator=(CachedPart &&other) +{ + delete mesh; + part = other.part; + texture = other.texture; + mesh = other.mesh; + other.mesh = nullptr; + return *this; +} + CachedPart::~CachedPart() { delete mesh; diff --git a/source/partcache.h b/source/partcache.h index 137bce4..8099676 100644 --- a/source/partcache.h +++ b/source/partcache.h @@ -16,6 +16,9 @@ struct CachedPart const GL::Texture2D *texture = nullptr; GL::Mesh *mesh = nullptr; + CachedPart() = default; + CachedPart(CachedPart &&); + CachedPart &operator=(CachedPart &&); ~CachedPart(); }; diff --git a/source/widget.h b/source/widget.h index 14d15fc..fc51798 100644 --- a/source/widget.h +++ b/source/widget.h @@ -2,6 +2,7 @@ #define MSP_GLTK_WIDGET_H_ #include +#include #include #include #include "geometry.h" @@ -21,7 +22,7 @@ class Style; /** Base class for all widgets. */ -class MSPGLTK_API Widget +class MSPGLTK_API Widget: public NonCopyable { friend class Container; @@ -58,9 +59,6 @@ protected: Time::TimeDelta anim_interval; Widget() = default; -private: - Widget(const Widget &); - Widget &operator=(const Widget &); public: virtual ~Widget();