X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.hh;h=0617b1a5c3094025331233fe4c8ced0a5742010e;hp=112b87ea8dba3ea07f8d1cbefe5407003e045b4e;hb=57b78ebe21b1b48acd337daa5a1cb8c383959cfa;hpb=c2321281bf12a7efaedde930422c7ddbc92080d4 diff --git a/src/Moof/Engine.hh b/src/Moof/Engine.hh index 112b87e..0617b1a 100644 --- a/src/Moof/Engine.hh +++ b/src/Moof/Engine.hh @@ -29,12 +29,13 @@ #ifndef _MOOF_ENGINE_HH_ #define _MOOF_ENGINE_HH_ +#include + #include -#include #include +#include #include -#include namespace Mf { @@ -43,15 +44,19 @@ namespace Mf { // forward declaration class Video; -class Engine : public Singleton +class Engine { +protected: + + Engine(int argc, char* argv[], const std::string& configFile, + const std::string& name, const std::string& iconFile); + public: - Engine(const std::string& name, int argc, char* argv[], - const std::string& configFile); + virtual ~Engine(); int run(); - void stop(); + void stop(int exitCode = 0); void setTimestep(Scalar ts); Scalar getTimestep(); @@ -61,14 +66,27 @@ 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 : public Mf::Exception + { + explicit Exception(unsigned error) : + Mf::Exception(error) {} + + void raise() + { + throw *this; + } + }; + private: - class EngineImpl; - boost::shared_ptr impl_; + Engine() {} // this class must be subclassed to be useful + + class Impl; + boost::shared_ptr impl_; };