X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fdispatcher.cc;h=d42077a2ec8b20a300051ae6f69e87b43ee4d775;hp=509b69d151bd039e5bf85d8f1d717e172c6321e7;hb=7d15b919681bb9ec0088b4b27c6abf62d6dfb9b1;hpb=0fffd0097d7b496454413e57b398c903ecc252e4 diff --git a/src/dispatcher.cc b/src/dispatcher.cc index 509b69d..d42077a 100644 --- a/src/dispatcher.cc +++ b/src/dispatcher.cc @@ -37,7 +37,7 @@ namespace dc { notification::~notification() {} -class dispatcher_impl +class dispatcher::dispatcher_impl { public: dispatcher_impl() : id(1) {} @@ -62,9 +62,11 @@ public: }; -dispatcher::dispatcher() : impl(new dispatcher_impl) {} +dispatcher::dispatcher() : impl(new dispatcher::dispatcher_impl) {} +// TODO these methods are ugly + dispatcher::handler dispatcher::addHandler(const std::string& message, const function& callback) { @@ -74,8 +76,8 @@ dispatcher::handler dispatcher::addHandler(const std::string& message, dispatcher::handler dispatcher::addHandler(const std::string& message, const function& callback, handler id) { - std::pair - callbackPair(message, dispatcher_impl::callback_t(id, callback)); + std::pair + callbackPair(message, dispatcher::dispatcher_impl::callback_t(id, callback)); std::pair handlerPair(id, message); @@ -88,16 +90,16 @@ dispatcher::handler dispatcher::addHandler(const std::string& message, void dispatcher::removeHandler(handler id) { - std::pair + std::pair handlers(impl->handlers.equal_range(id)); - dispatcher_impl::handler_it_t i; + dispatcher::dispatcher_impl::handler_it_t i; for (i = handlers.first; i != handlers.second; i++) { - dispatcher_impl::callback_it_t it = impl->callbacks.find((*i).second); - dispatcher_impl::callback_it_t last = impl->callbacks.end(); + dispatcher::dispatcher_impl::callback_it_t it = impl->callbacks.find((*i).second); + dispatcher::dispatcher_impl::callback_it_t last = impl->callbacks.end(); - dispatcher_impl::callback_it_t j; + dispatcher::dispatcher_impl::callback_it_t j; for (j = it; j != last; j++) { if (((*j).second).first == id) @@ -119,10 +121,10 @@ void dispatcher::dispatch(const std::string& message) void dispatcher::dispatch(const std::string& message, const notification& param) { - std::pair + std::pair callbacks(impl->callbacks.equal_range(message)); - dispatcher_impl::callback_it_t i; + dispatcher::dispatcher_impl::callback_it_t i; for (i = callbacks.first; i != callbacks.second; i++) { function callback = ((*i).second).second; @@ -133,3 +135,5 @@ void dispatcher::dispatch(const std::string& message, const notification& param) } // namespace dc +/** vim: set ts=4 sw=4 tw=80: *************************************************/ +