class Dispatcher
{
+ class Impl;
+ boost::shared_ptr<Impl> impl_;
+
public:
+
typedef void* Handler;
typedef boost::function<void(const Notification*)> Function;
void removeHandler(Handler id);
void dispatch(const std::string& message, const Notification* param = 0);
-
-private:
- class Impl;
- boost::shared_ptr<Impl> impl_;
};
+namespace dispatcher {
+
+inline Dispatcher::Handler addHandler(const std::string& message,
+ const Dispatcher::Function& callback)
+{
+ Dispatcher::getInstance().addHandler(message, callback);
+}
+
+inline Dispatcher::Handler addHandler(const std::string& message,
+ const Dispatcher::Function& callback, Dispatcher::Handler id)
+{
+ Dispatcher::getInstance().addHandler(message, callback, id);
+}
+
+inline void removeHandler(Dispatcher::Handler id)
+{
+ Dispatcher::getInstance().removeHandler(id);
+}
+
+inline void dispatch(const std::string& message, const Notification* param = 0)
+{
+ Dispatcher::getInstance().dispatch(message, param);
+}
+
+} // namespace dispatch
+
} // namespace Mf
#endif // _MOOF_DISPATCHER_HH_
music("NightFusion"),
punchSound("RobotPunch")
{
- Mf::Dispatcher::getInstance().addHandler("video.context_recreated",
+ Mf::dispatcher::addHandler("video.context_recreated",
boost::bind(&YoinkApp::contextRecreated, this, _1), this);
setupGL();
delete font;
delete testScene;
- Mf::Dispatcher::getInstance().removeHandler(this);
+ Mf::dispatcher::removeHandler(this);
}
}
else if (event.key.keysym.sym == SDLK_t)
{
- Mf::Dispatcher::getInstance().dispatch("video.context_recreated");
+ Mf::dispatcher::dispatch("video.context_recreated");
break;
}
else if (event.key.keysym.sym == SDLK_p)