X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2FMoof%2FDispatch.hh;fp=src%2FMoof%2FDispatch.hh;h=0000000000000000000000000000000000000000;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hp=e357f0263e65d33aac5ec81972f9437e22abf0a5;hpb=299af4f2047e767e5d79501c26444473bda64c64;p=chaz%2Fyoink diff --git a/src/Moof/Dispatch.hh b/src/Moof/Dispatch.hh deleted file mode 100644 index e357f02..0000000 --- a/src/Moof/Dispatch.hh +++ /dev/null @@ -1,103 +0,0 @@ - -/*] Copyright (c) 2009-2010, 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. -* -**************************************************************************/ - -#ifndef _MOOF_DISPATCH_HH_ -#define _MOOF_DISPATCH_HH_ - -#include - -#include -#include -#include -#include - - -namespace Mf { - - -/** - * Dispatcher of messages to interested parties. - */ - -class Dispatch -{ - class Impl; - boost::shared_ptr mImpl; - - void removeTarget(unsigned id); - - -public: - - class Handle - { - public: - - Handle() : - mId(0) {} - - Handle(boost::weak_ptr dispatch, unsigned id) : - mDispatch(dispatch), - mId(id) {} - - Handle(const Handle& handle) : - mDispatch(handle.mDispatch), - mId(handle.mId) - { - handle.mId = 0; - } - - ~Handle() - { - clear(); - } - - Handle& operator = (const Handle& handle) - { - clear(); - mDispatch = handle.mDispatch; - mId = handle.mId; - handle.mId = 0; - return *this; - } - - unsigned getId() const - { - return mId; - } - - void clear(); - - private: - - boost::weak_ptr mDispatch; - mutable unsigned mId; - }; - - typedef boost::function Function; - - - Dispatch(); - - Handle addTarget(const std::string& event, const Function& callback); - Handle addTarget(const std::string& event, const Function& callback, - Handle handle); - - void dispatch(const std::string& event); - - static Dispatch& global(); -}; - - -} // namespace Mf - -#endif // _MOOF_DISPATCH_HH_ -