33 #ifndef __H__UG__message_hub_impl__
34 #define __H__UG__message_hub_impl__
45 typedef void (*FuncCallback)(
const IMessage&);
47 return register_callback_impl<TMsg>((FuncCallback)callback, autoFree);
51 template <
class TMsg,
class TClass>
54 void (TClass::*callback)(
const TMsg&),
57 typedef void (TClass::*ClassCallback)(
const IMessage&);
59 return register_callback_impl<TMsg>(
60 boost::bind((ClassCallback)callback, cls, _1),
70 size_t id = GetUniqueTypeID<TMsg>();
73 for(CallbackEntryList::iterator iter = callbacks.begin();
74 iter != callbacks.end(); ++iter)
76 iter->m_callback(msg);
86 size_t id = GetUniqueTypeID<TMsg>();
93 cbIter->m_callbackId = cbId;
The callback-id allows to deregister previously registered callbacks.
Definition: message_hub.h:148
This is the base class of all messages, which may be passed to callbacks.
Definition: message_hub.h:133
CallbackEntryList::iterator CallbackEntryIterator
Definition: message_hub.h:103
CallbackMap m_callbackMap
given a msg-type-id, this map returns a list of associated callbacks
Definition: message_hub.h:246
std::list< CallbackEntry > CallbackEntryList
Definition: message_hub.h:102
void post_message(const TMsg &msg)
Posts a message to all callbacks which are registered for the given message tpye.
Definition: message_hub_impl.hpp:67
SPCallbackId register_callback_impl(boost::function< void(const IMessage &)> callback, bool autoFree)
registers a callback given a message-id.
Definition: message_hub_impl.hpp:83
SmartPtr< CallbackId > SPCallbackId
Definition: message_hub.h:166
SPCallbackId register_class_callback(TClass *cls, void(TClass::*callback)(const TMsg &), bool autoFree=true)
registers a method callback given a message-type.
Definition: message_hub_impl.hpp:53
SPCallbackId register_function_callback(void(*callback)(const TMsg &), bool autoFree=false)
registers a function callback given a message-type.
Definition: message_hub_impl.hpp:42
The CallbackEntry holds the actual callback and the associated callback-id.
Definition: message_hub.h:96