#include <Moof/Dispatcher.hh>
#include <Moof/Event.hh>
+#include <Moof/Exception.hh>
#include <Moof/Math.hh>
-#include <Moof/Singleton.hh>
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();
- void stop();
+ void stop(int exitCode = 0);
void setTimestep(Scalar ts);
Scalar getTimestep();
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<EngineImpl> impl_;
+ Engine() {} // this class must be subclassed to be useful
+
+ class Impl;
+ boost::shared_ptr<Impl> impl_;
};