X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FEngine.hh;h=e42510d3d86af61744bab076f2186249e1e91e26;hb=bffc879fc8ee8167bb123310d39fad4e2f426ffd;hp=aa751356f6a81b6ec1712cf1ee7bdf322384d749;hpb=a5f0d391406a68275b41448fc3f49e8d8396c497;p=chaz%2Fyoink diff --git a/src/Moof/Engine.hh b/src/Moof/Engine.hh index aa75135..e42510d 100644 --- a/src/Moof/Engine.hh +++ b/src/Moof/Engine.hh @@ -29,59 +29,59 @@ #ifndef _MOOF_ENGINE_HH_ #define _MOOF_ENGINE_HH_ -#include - #include -#include -#include +#include +#include #include namespace Mf { -// forward declaration +// forward declarations class Video; class Engine { -protected: - - Engine(int argc, char* argv[], const std::string& configFile, - const std::string& name, const std::string& iconFile); + class Impl; + boost::shared_ptr mImpl; public: - virtual ~Engine(); + Engine(int argc, char* argv[], const std::string& name, + const std::string& iconFile, const std::string& configFile); + ~Engine() {} + + // get global instance + static Engine& getInstance(); - int run(); - void stop(int exitCode = 0); + void run(); void setTimestep(Scalar ts); - Scalar getTimestep(); + Scalar getTimestep() const; void setMaxFrameRate(long maxFps); - long getMaxFrameRate(); + long getMaxFrameRate() const; - Video& getVideo(); - long getFrameRate(); + Video& getVideo() const; + long getFrameRate() const; - // override these if you want - virtual void update(Scalar t, Scalar dt); - virtual void draw(Scalar alpha); - virtual void handleEvent(const Event& event); + void push(LayerP layer); + LayerP pop(); + // pops a specific layer and all layers above it + LayerP pop(Layer* layer); + void clear(); - struct Exception : std::runtime_error + struct Exception : public Mf::Exception { - explicit Exception(const std::string& what_arg) : - std::runtime_error(what_arg) {} - }; - -private: - Engine() {} // this class must be subclassed to be useful + explicit Exception(unsigned error) : + Mf::Exception(error) {} - class Impl; - boost::shared_ptr impl_; + void raise() + { + throw *this; + } + }; };