]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/demo.h
Framework for loading sequences from files
[libs/demoscene.git] / source / demo.h
index 2f40cf8df577e4f8796a1f53401d46de9ae7cd2e..77eb671601fc52f79386b341acf06777d7e1c07a 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MSP_DEMOSCENE_DEMO_H_
 #define MSP_DEMOSCENE_DEMO_H_
 
+#include <map>
+#include <string>
 #include <sigc++/signal.h>
 #include <msp/al/sounddecoder.h>
 #include <msp/al/source.h>
@@ -26,10 +28,15 @@ protected:
        Msp::Time::TimeStamp last_tick;
        Msp::Time::TimeStamp next_frame;
 
+       std::map<std::string, Msp::Variant> things;
+
        Demo(Msp::Graphics::Window &, Msp::Graphics::GLContext &, Msp::DataFile::Collection &);
 public:
        virtual ~Demo();
 
+       template<typename T>
+       T &get_thing(const std::string &);
+
        void set_fixed_framerate(float);
        const Msp::Time::TimeStamp &get_next_frame_time() const { return next_frame; }
        void enable_music();
@@ -38,5 +45,10 @@ public:
        void seek(const Msp::Time::TimeDelta &);
 };
 
+template<typename T>
+T &Demo::get_thing(const std::string &name)
+{
+       return *get_item(things, name).value<T *>();
+}
 
 #endif