X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FDispatcher.hh;h=da82f3824256b70bf50ee283f446133594a1c009;hp=a152691a8184d170d62890df2fb72dbc51959dc2;hb=f72400af4fa3e7b54dab154b5a2b6503a6f9af18;hpb=3cba2347188d70f5ee6e401774b8f86acfd1a3b9 diff --git a/src/Moof/Dispatcher.hh b/src/Moof/Dispatcher.hh index a152691..da82f38 100644 --- a/src/Moof/Dispatcher.hh +++ b/src/Moof/Dispatcher.hh @@ -55,7 +55,11 @@ public: class Dispatcher { + class Impl; + boost::shared_ptr impl_; + public: + typedef void* Handler; typedef boost::function Function; @@ -72,13 +76,35 @@ public: void removeHandler(Handler id); void dispatch(const std::string& message, const Notification* param = 0); - -private: - class Impl; - boost::shared_ptr 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_