]> Dogcows Code - chaz/yoink/blobdiff - src/moof/dispatcher.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / dispatcher.cc
index 96babe48194eb1d91243ccad2fa412cf10207e72..c0aeae5c3ec6c3bafca835d3cd7f02c7a4abbf8e 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <map>
 
@@ -25,29 +23,25 @@ public:
                dispatcher_(dispatcher),
                id_(0) {}
 
-       dispatcher::handle getNewHandle()
+       dispatcher::handle new_handle()
        {
-               ++id_;
-               dispatcher::handle handle(dispatcher_->impl_, id_);
+               dispatcher::handle handle(dispatcher_->impl_, --id_);
                return handle;
        }
 
        typedef std::pair<unsigned,dispatcher::function>        callback;
-       typedef std::multimap<std::string,callback>                     callback_lookup;
-       typedef callback_lookup::iterator                                       callback_it;
-
-       typedef std::multimap<unsigned,std::string>                     handle_lookup;
-       typedef handle_lookup::iterator                                         handle_it;
+       typedef std::multimap<std::string,callback>             callback_lookup;
+       typedef callback_lookup::iterator                       callback_it;
 
+       typedef std::multimap<unsigned,std::string>             handle_lookup;
+       typedef handle_lookup::iterator                         handle_it;
 
        handle add_target(const std::string& event,
-                                         const function& callback,
-                                         handle handle)
+                       const function& callback, handle handle)
        {
-               callbacks_.insert(std::make_pair(event, std::make_pair(handle.id(),
-                                                                                                                          callback)));
+               callbacks_.insert(std::make_pair(event,
+                                       std::make_pair(handle.id(), callback)));
                handles_.insert(std::make_pair(handle.id(), event));
-
                return handle;
        }
 
@@ -55,7 +49,8 @@ public:
        {
                std::pair<handle_it,handle_it> matching(handles_.equal_range(id));
 
-               for (handle_it it = matching.first; it != matching.second; ++it)
+               for (handle_it it = matching.first;
+                               it != matching.second; ++it)
                {
                        callback_it first = callbacks_.find((*it).second);
                        callback_it last = callbacks_.end();
@@ -85,16 +80,13 @@ public:
                }
        }
 
-
-       dispatcher*             dispatcher_;
-
-       unsigned                id_;
+       dispatcher*     dispatcher_;
+       unsigned        id_;
 
        callback_lookup callbacks_;
        handle_lookup   handles_;
 };
 
-
 void dispatcher::handle::clear()
 {
        boost::shared_ptr<impl> dispatcher;
@@ -109,36 +101,31 @@ void dispatcher::handle::clear()
 dispatcher::dispatcher() :
        impl_(new dispatcher::impl(this)) {}
 
-
-dispatcher::handle dispatcher::add_target(const std::string& event,
-                                                                                 const function& callback)
+dispatcher::handle
+dispatcher::add_target(const std::string& event, const function& callback)
 {
-       return add_target(event, callback, impl_->getNewHandle());
+       return add_target(event, callback, impl_->new_handle());
 }
 
 dispatcher::handle dispatcher::add_target(const std::string& event,
-                                                                                 const function& callback,
-                                                                                 handle handle)
+               const function& callback, handle handle)
 {
        // pass through
        return impl_->add_target(event, callback, handle);
 }
 
-
 void dispatcher::remove_target(unsigned id)
 {
        // pass through
        return impl_->remove_target(id);
 }
 
-
 void dispatcher::dispatch(const std::string& event)
 {
        // pass through
        impl_->dispatch(event);
 }
 
-
 dispatcher& dispatcher::global()
 {
        static dispatcher dispatcher;
This page took 0.022325 seconds and 4 git commands to generate.