#include <CSMessageListener.h>
Inheritance diagram for CSMessageListener:
The method to dispatch a message to a (n allways given) listerner is:
The message itself "knows" if it is a message that must be dispatched at once - or at a later point in time.
If the message is to be dispatched at one, the method:
virtual void reactOnMessage(CSMessage *message) = 0;will be called.
(But this should not be called by a client, this method is called by CSMEessageDispatchable. The client, that wishes to "send a message" should allways use the method:void sendMessage(CSMessage &message);of the CSMEessageDispatchable class!)
All classes implementing "CSMessageListener", must implement that method.
Otherwise (if the message is supposed to be dispatched later), the message AND the listener is added to a static Vector. At the apropriate time some "HANDLER" (main look...) must call:
At that point all pending messaged will be send to the corresponing listeners.
Definition at line 58 of file CSMessageListener.h.
Public Member Functions | |
CSMessageListener () | |
virtual | ~CSMessageListener () |
virtual std::string | getType () |
virtual void | dispatchMessage (CSMessage *message) |
virtual void | reactOnMessage (CSMessage *message)=0 |
Static Public Member Functions | |
void | dispatchQueuedMessages () |
Static Public Attributes | |
const char * | CLASS = "CSMessageListener" |
Static Protected Member Functions | |
void | addMessageToQueue (CSMessageListener *listener, CSMessage *message) |
|
Definition at line 11 of file CSMessageListener.cpp. References LOG_ENTER, and LOG_EXIT.
|
|
Definition at line 18 of file CSMessageListener.cpp. References LOG_ENTER, and LOG_EXIT.
|
|
Definition at line 25 of file CSMessageListener.cpp. References CSInternalMessage::listener, and CSInternalMessage::message. Referenced by dispatchMessage().
00026 { 00027 static char *functionName="addMessageToQueue"; 00028 if (listener == 0) 00029 { 00030 return; 00031 } 00032 00033 CSInternalMessage *iMessage = new CSInternalMessage(); 00034 iMessage->listener = listener; 00035 iMessage->message = message; 00036 mCSInternalMessages.push_back(iMessage); 00037 } |
|
Reimplemented in CSBar, CSButton, CSDragButton, CSCheckBox, CSCombobox, CSDesktop, CSGrafikElement, CSHTMLPanel, CSIcon, CSPictureIcon, CSTextIcon, CSLabel, CSListbox, CSMenu, CSMenuBar, CSMenuItem, CSMessageBox, CSPanel, CSScrollbar, CSTextarea, CSTextfield, CSWindow, CSGame, and CSSprite. Definition at line 71 of file CSMessageListener.h. References CLASS.
00071 {return (std::string) CLASS;} |
|
Definition at line 39 of file CSMessageListener.cpp. References CSInternalMessage::listener, CSInternalMessage::message, and reactOnMessage(). Referenced by CSGame::run().
00040 { 00041 static char *functionName="dispatchQueuedMessages"; 00042 CSInternalMessages::iterator iter; 00043 for (iter = mCSInternalMessages.begin(); iter != mCSInternalMessages.end(); iter++) 00044 { 00045 CSInternalMessage *iMessage = *iter; 00046 iMessage->listener->reactOnMessage(iMessage->message); 00047 delete(iMessage); 00048 } 00049 mCSInternalMessages.clear(); 00050 } |
Here is the call graph for this function:
|
Definition at line 52 of file CSMessageListener.cpp. References addMessageToQueue(), CSMessage::isDispatchAtOnce(), and reactOnMessage(). Referenced by CSMessageDispatchable::sendMessage().
00053 { 00054 static char *functionName="dispatchMessage"; 00055 if (!message->isDispatchAtOnce()) 00056 { 00057 addMessageToQueue(this, message); 00058 return; 00059 } 00060 reactOnMessage(message); 00061 } |
Here is the call graph for this function:
|
Implemented in CSButton, CSDragButton, CSCheckBox, CSCombobox, CSGrafikElement, CSHTMLPanel, CSListbox, CSMenu, CSMenuItem, CSScrollbar, CSTextarea, CSTextfield, CSWindow, CSGame, and CSSprite. Referenced by dispatchMessage(), and dispatchQueuedMessages(). |
|
Reimplemented in CSBar, CSButton, CSDragButton, CSCheckBox, CSCombobox, CSDesktop, CSGrafikElement, CSHTMLPanel, CSIcon, CSPictureIcon, CSTextIcon, CSLabel, CSListbox, CSMenu, CSMenuBar, CSMenuItem, CSMessageBox, CSPanel, CSScrollbar, CSTextarea, CSTextfield, CSWindow, CSGame, and CSSprite. Definition at line 9 of file CSMessageListener.cpp. Referenced by getType(). |