]>
Dogcows Code - chaz/yoink/blob - src/Moof/Dispatch.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #ifndef _MOOF_DISPATCH_HH_
13 #define _MOOF_DISPATCH_HH_
17 #include <boost/bind.hpp>
18 #include <boost/function.hpp>
19 #include <boost/shared_ptr.hpp>
20 #include <boost/weak_ptr.hpp>
27 * Dispatcher of messages to interested parties.
33 boost::shared_ptr
<Impl
> mImpl
;
35 void removeTarget(unsigned id
);
40 * Interface for a notification class.
46 virtual ~Message() {};
57 Handle(boost::weak_ptr
<Impl
> dispatch
, unsigned id
) :
61 Handle(const Handle
& handle
) :
62 mDispatch(handle
.mDispatch
),
73 Handle
& operator = (const Handle
& handle
)
76 mDispatch
= handle
.mDispatch
;
82 unsigned getId() const
91 boost::weak_ptr
<Impl
> mDispatch
;
95 typedef boost::function
<void(const Message
*)> Function
;
100 Handle
addTarget(const std::string
& event
, const Function
& callback
);
101 Handle
addTarget(const std::string
& event
, const Function
& callback
,
104 void dispatch(const std::string
& event
, const Message
* message
= 0);
106 static Dispatch
& global();
112 #endif // _MOOF_DISPATCH_HH_
This page took 0.036323 seconds and 4 git commands to generate.