X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2FMoof%2FEngine.hh;h=0617b1a5c3094025331233fe4c8ced0a5742010e;hb=25aefe01ef7dbdb603c51411e04b0d6a6107684f;hp=2d7dfd6aa77b9ee56ebb591f7e7954c15b69875a;hpb=16d1a05b0777e97a45c48e2874aa4e5cc791282e;p=chaz%2Fyoink diff --git a/src/Moof/Engine.hh b/src/Moof/Engine.hh index 2d7dfd6..0617b1a 100644 --- a/src/Moof/Engine.hh +++ b/src/Moof/Engine.hh @@ -33,10 +33,9 @@ #include -#include #include +#include #include -#include namespace Mf { @@ -45,15 +44,19 @@ namespace Mf { // forward declaration class Video; -class Engine : public Singleton +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(); - void stop(); + void stop(int exitCode = 0); void setTimestep(Scalar ts); Scalar getTimestep(); @@ -63,20 +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 : 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: - class EngineImpl; - boost::shared_ptr impl_; + Engine() {} // this class must be subclassed to be useful + + class Impl; + boost::shared_ptr impl_; };