have Actors automatically subscribe to a message for each command that ends in "MessageCommand"

This commit is contained in:
Chris Danford
2005-02-23 18:53:54 +00:00
parent ed044bd2f9
commit 2e5b94e064
4 changed files with 67 additions and 20 deletions
+8 -4
View File
@@ -5,8 +5,12 @@
#include <set>
#include <map>
class Actor;
class IMessageSubscriber
{
public:
virtual void HandleMessage( const CString& sMessage ) = 0;
};
class MessageManager
{
@@ -14,12 +18,12 @@ public:
MessageManager();
~MessageManager();
void Subscribe( Actor* pActor, const CString& sMessage );
void Unsubscribe( Actor* pActor, const CString& sMessage );
void Subscribe( IMessageSubscriber* pSubscriber, const CString& sMessage );
void Unsubscribe( IMessageSubscriber* pSubscriber, const CString& sMessage );
void Broadcast( const CString& sMessage );
private:
typedef set<Actor*> SubscribersSet;
typedef set<IMessageSubscriber*> SubscribersSet;
map<CString,SubscribersSet> m_MessageToSubscribers;
};