All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ImmediateMessageBus.h
1 // Copyright (c) 2014 eeGeo. All rights reserved.
2 
3 #pragma once
4 
5 #include "CatalogBinding.h"
6 #include "Types.h"
7 
8 namespace Eegeo
9 {
10  namespace Messaging
11  {
12  template <typename TMessageCatalog>
14  {
15  private:
16  TMessageCatalog m_catalog;
17 
18  public:
19  template <typename TMessage>
20  void Publish(const TMessage& message)
21  {
22  CatalogBinding<TMessage>& binding(m_catalog);
23  binding.Dispatch(message);
24  }
25 
26  template <typename TMessage>
27  void Subscribe(Eegeo::Helpers::ICallback1<const TMessage&>& handler)
28  {
29  CatalogBinding<TMessage>& binding(m_catalog);
30  binding.Subscribe(handler);
31  }
32 
33  template <typename TMessage>
34  void Unsubscribe(Eegeo::Helpers::ICallback1<const TMessage&>& handler)
35  {
36  CatalogBinding<TMessage>& binding(m_catalog);
37  binding.Unsubscribe(handler);
38  }
39 
40  void Flush() { }
41  };
42  }
43 }