5 #include "CatalogBinding.h"
6 #include "MessageQueue.h"
12 template <
typename TMessageCatalog>
16 TMessageCatalog m_catalog;
21 virtual ~MessageInfo() {};
22 virtual void Dispatch() = 0;
25 template <
typename TMessage>
26 class TypedMessageInfo :
public MessageInfo
30 TMessageCatalog& m_catalog;
32 TypedMessageInfo(
const TMessage& message,
33 TMessageCatalog& catalog)
42 binding.Dispatch(m_message);
49 template <
typename TMessage>
50 void Publish(
const TMessage& message)
52 m_messages.Enqueue(
new TypedMessageInfo<TMessage>(message, m_catalog));
55 template <
typename TMessage>
59 binding.Subscribe(handler);
62 template <
typename TMessage>
66 binding.Unsubscribe(handler);
72 while (m_messages.TryDequeue(info))