]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/partcache.h
Simplify constructors with C++11
[libs/gltk.git] / source / partcache.h
index 90d1c94f5e36e90a19614cc39a9e8a56033d7945..af697339efcfa0ed5e46cb998235e0c156ac13c0 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,20 +12,30 @@ class Part;
 
 struct CachedPart
 {
-       const Part *part;
-       const GL::Texture2D *texture;
-       GL::Mesh *mesh;
+       const Part *part = 0;
+       const GL::Texture2D *texture = 0;
+       GL::Mesh *mesh = 0;
 
-       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 = false;
        PartList parts;
        PartList::iterator next;
        PartList::iterator current;