Fission FSN
Loading...
Searching...
No Matches
fsIMessageDispatcher.h
Go to the documentation of this file.
1/********************************************************************
2*
3* Created: 4/3/2014 11:49
4*
5* File: fsIMessageDispatcher.h
6*
7* Author: Mick Waites
8*
9* Purpose: Base class for any message transmitting classes. All
10* messages are sent to listeners in the order that they
11* register themselves.
12*
13*********************************************************************/
14
15#ifndef fsIMessageDispatcherhdr
16#define fsIMessageDispatcherhdr
17
18#include <map>
19#include <vector>
20
22#include <fsCore/fsBaseTypes.h>
23
25
26
28{
29public:
30
32 {
34 {
35 }
36 };
37
39 {
40 sStrMessageParam() = default;
41 explicit sStrMessageParam(const fsStr& pStr) : mStr(pStr) {}
43 };
44
48
49 void listenerRegister(const fsCUniqueId& pMessageType, fsIMessageListener* pListener);
50 void listenerDeregister(const fsCUniqueId& pMessageType, fsIMessageListener* pListener);
51
52 fsBool messageDispatch(const fsCUniqueId& pMessageType, const sMessageParameters& pParam);
53
55
56protected:
57
58 virtual fsBool messageDispatchDo(const fsCUniqueId& pMessageType, const sMessageParameters& pParam);
59
61 virtual ~fsIMessageDispatcher();
62
63private:
64
65 void pendingListenerRegistrationsProcess();
66
67 fsBool mInDispatch;
68
69 fsIMessageListener* mPriorityListener;
70
71 std::map<fsCUniqueId, std::vector<fsIMessageListener*>> mMsgTypes;
72 std::vector<std::pair<fsIMessageListener*, fsCUniqueId>> mListenersToRegister;
73 std::vector<std::pair<fsIMessageListener*, fsCUniqueId>> mListenersToDeregister;
74};
75
76#endif
Definition fsCUniqueId.h:21
void priorityListenerDeregister(fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:28
fsBool messageDispatch(const fsCUniqueId &pMessageType, const sMessageParameters &pParam)
Definition fsIMessageDispatcher.cpp:123
virtual ~fsIMessageDispatcher()
Definition fsIMessageDispatcher.cpp:168
virtual fsBool messageDispatchDo(const fsCUniqueId &pMessageType, const sMessageParameters &pParam)
Definition fsIMessageDispatcher.cpp:128
void priorityListenerButtonClear()
Definition fsIMessageDispatcher.cpp:14
fsIMessageDispatcher()
Definition fsIMessageDispatcher.cpp:162
void listenerDeregister(const fsCUniqueId &pMessageType, fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:69
static sMessageParameters mNullParam
Definition fsIMessageDispatcher.h:54
void listenerRegister(const fsCUniqueId &pMessageType, fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:38
void priorityListenerRegister(fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:22
Definition fsIMessageListener.h:24
Definition fsStr.h:23
bool fsBool
Definition fsBaseTypes.h:26
Definition fsIMessageDispatcher.h:32
virtual ~sMessageParameters()
Definition fsIMessageDispatcher.h:33
fsStr mStr
Definition fsIMessageDispatcher.h:42
sStrMessageParam(const fsStr &pStr)
Definition fsIMessageDispatcher.h:41