]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Engine.hh
better logging (maybe) and exception handling
[chaz/yoink] / src / Moof / Engine.hh
index 971d68fe1e28eb59e3536056dd19c4355ec0668c..f088dc56e85fcb663766594a2c9b454788e7c519 100644 (file)
@@ -35,8 +35,8 @@
 
 #include <Moof/Dispatcher.hh>
 #include <Moof/Event.hh>
+#include <Moof/Exception.hh>
 #include <Moof/Math.hh>
-#include <Moof/Singleton.hh>
 
 
 namespace Mf {
@@ -45,11 +45,15 @@ namespace Mf {
 // forward declaration
 class Video;
 
-class Engine : public Singleton<Engine>
+class Engine
 {
-public:
+protected:
+
        Engine(int argc, char* argv[], const std::string& configFile,
                        const std::string& name, const std::string& iconFile);
+
+public:
+
        virtual ~Engine();
 
        int run();
@@ -63,18 +67,25 @@ public:
        Video& getVideo();
        long getFrameRate();
 
-       // Override these if you want.
+       // override these if you want
        virtual void update(Scalar t, Scalar dt);
        virtual void draw(Scalar alpha);
        virtual void handleEvent(const Event& event);
 
-       struct Exception : std::runtime_error
+       struct Exception : public Mf::Exception
        {
-               explicit Exception(const std::string& what_arg) :
-                       std::runtime_error(what_arg) {}
+               explicit Exception(unsigned error) :
+                       Mf::Exception(error) {}
+
+               void raise()
+               {
+                       throw *this;
+               }
        };
 
 private:
+       Engine() {} // this class must be subclassed to be useful
+
        class Impl;
        boost::shared_ptr<Impl> impl_;
 };
This page took 0.01908 seconds and 4 git commands to generate.