]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/partcache.h
Use nullptr instead of 0 for pointers
[libs/gltk.git] / source / partcache.h
index 969912431271d501b68267f9f09bb7b05f0427b6..137bce4c37539a8c032f27b36cff0c35afc89f58 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <msp/gl/mesh.h>
 #include <msp/gl/texture2d.h>
+#include "mspgltk_api.h"
 
 namespace Msp {
 namespace GLtk {
@@ -11,28 +12,35 @@ class Part;
 
 struct CachedPart
 {
-       const Part *part;
-       const GL::Texture2D *texture;
-       GL::Mesh *mesh;
+       const Part *part = nullptr;
+       const GL::Texture2D *texture = nullptr;
+       GL::Mesh *mesh = nullptr;
 
-       CachedPart();
        ~CachedPart();
 };
 
-class PartCache
+class MSPGLTK_API PartCache
 {
 public:
+       class Rebuild
+       {
+       private:
+               PartCache &cache;
+
+       public:
+               Rebuild(PartCache &c): cache(c) { cache.begin_rebuild(); }
+               ~Rebuild() { cache.end_rebuild(); }
+       };
+
        typedef std::list<CachedPart> PartList;
 
 private:
-       bool rebuilding;
+       bool rebuilding = false;
        PartList parts;
        PartList::iterator next;
        PartList::iterator current;
 
 public:
-       PartCache();
-
        void begin_rebuild();
        void insert_special(const Part &);
        GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);