#include <string>
+#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
class Notification
{
public:
- virtual ~Notification();
+ virtual ~Notification() {};
};
class Dispatcher
{
class Impl;
- boost::shared_ptr<Impl> impl_;
+ boost::shared_ptr<Impl> mImpl;
public:
+ // TODO - the Handler would be even better as an object which automagically
+ // removes itself from the dispatcher on destruction, so users don't have to
+ // worry about forgetting
typedef void* Handler;
typedef boost::function<void(const Notification*)> Function;
inline Dispatcher::Handler addHandler(const std::string& message,
const Dispatcher::Function& callback)
{
- Dispatcher::getInstance().addHandler(message, callback);
+ return 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);
+ return Dispatcher::getInstance().addHandler(message, callback, id);
}
inline void removeHandler(Dispatcher::Handler id)
Dispatcher::getInstance().dispatch(message, param);
}
-} // namespace dispatch
+} // namespace dispatcher
+
} // namespace Mf