]> git.tdb.fi Git - libs/gltk.git/commitdiff
Make sure classes follow the rule of 0/3/5
authorMikko Rasa <tdb@tdb.fi>
Sun, 20 Aug 2023 20:51:25 +0000 (23:51 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 20 Aug 2023 21:52:42 +0000 (00:52 +0300)
source/arrangement.h
source/partcache.cpp
source/partcache.h
source/widget.h

index 15fb47ce328f92539e97b99a467544ae947ed641..4a651bac864a189cbb8c2942e35390939c2bff38 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <list>
 #include <stdexcept>
+#include <msp/core/noncopyable.h>
 #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
index f4c085e5baa47c4230786eba92a2feb50ac8cf50..77b51d2cbc2096a101eb941b20e45f6b23568c6a 100644 (file)
@@ -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;
index 137bce4c37539a8c032f27b36cff0c35afc89f58..8099676f95d177ecc3855bf00006db2a3aa11263 100644 (file)
@@ -16,6 +16,9 @@ struct CachedPart
        const GL::Texture2D *texture = nullptr;
        GL::Mesh *mesh = nullptr;
 
+       CachedPart() = default;
+       CachedPart(CachedPart &&);
+       CachedPart &operator=(CachedPart &&);
        ~CachedPart();
 };
 
index 14d15fc7a5678a33fed2062b81d530719e62cabc..fc517989364c899a4d315585ad2de04552653eaa 100644 (file)
@@ -2,6 +2,7 @@
 #define MSP_GLTK_WIDGET_H_
 
 #include <string>
+#include <msp/core/noncopyable.h>
 #include <msp/datafile/objectloader.h>
 #include <msp/gl/renderer.h>
 #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();