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 const fsIMessageListener* priorityListenerGet() const { return mPriorityListener; }
49
50 void listenerRegister(const fsCUniqueId& pMessageType, fsIMessageListener* pListener);
51 void listenerDeregister(const fsCUniqueId& pMessageType, fsIMessageListener* pListener);
52
53 fsBool messageDispatch(const fsCUniqueId& pMessageType, const sMessageParameters& pParam);
54
56
57protected:
58
59 virtual fsBool messageDispatchDo(const fsCUniqueId& pMessageType, const sMessageParameters& pParam);
60
62 virtual ~fsIMessageDispatcher();
63
64private:
65
66 void pendingListenerRegistrationsProcess();
67
68 fsBool mInDispatch;
69
70 fsIMessageListener* mPriorityListener;
71
72 std::map<fsCUniqueId, std::vector<fsIMessageListener*>> mMsgTypes;
73 std::vector<std::pair<fsIMessageListener*, fsCUniqueId>> mListenersToRegister;
74 std::vector<std::pair<fsIMessageListener*, fsCUniqueId>> mListenersToDeregister;
75};
76
77#endif
Definition fsCUniqueId.h:21
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
const fsIMessageListener * priorityListenerGet() const
Definition fsIMessageDispatcher.h:48
fsIMessageDispatcher()
Definition fsIMessageDispatcher.cpp:162
void listenerDeregister(const fsCUniqueId &pMessageType, fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:69
static sMessageParameters mNullParam
Definition fsIMessageDispatcher.h:55
void listenerRegister(const fsCUniqueId &pMessageType, fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:38
void priorityListenerDeregister(const fsIMessageListener *pListener)
Definition fsIMessageDispatcher.cpp:28
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