add experimental MessageManager

This commit is contained in:
Chris Danford
2005-02-09 05:20:49 +00:00
parent c99043b7f2
commit 613b99d26f
6 changed files with 147 additions and 6 deletions
+2 -1
View File
@@ -275,7 +275,8 @@ FontManager.cpp FontManager.h GameSoundManager.cpp GameSoundManager.h GameManage
GameState.cpp GameState.h InputFilter.cpp InputFilter.h \
InputMapper.cpp InputMapper.h InputQueue.cpp InputQueue.h \
LuaManager.cpp LuaManager.h LightsManager.cpp LightsManager.h \
MemoryCardManager.cpp MemoryCardManager.h NetworkSyncManager.cpp NetworkSyncManager.h \
MemoryCardManager.cpp MemoryCardManager.h \
MessageManager.cpp MessageManager.h NetworkSyncManager.cpp NetworkSyncManager.h \
NetworkSyncServer.cpp NetworkSyncServer.h NoteSkinManager.cpp NoteSkinManager.h \
PrefsManager.cpp PrefsManager.h ProfileManager.cpp ProfileManager.h ScreenManager.cpp \
ScreenManager.h SongManager.cpp SongManager.h ThemeManager.cpp ThemeManager.h \
+67
View File
@@ -0,0 +1,67 @@
#include "global.h"
#include "MessageManager.h"
#include "Foreach.h"
#include "Actor.h"
#include "RageUtil.h"
MessageManager* MESSAGEMAN = NULL; // global and accessable from anywhere in our program
MessageManager::MessageManager()
{
}
MessageManager::~MessageManager()
{
}
void MessageManager::Subscribe( Actor* pActor, const CString& sMessage )
{
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
#if _DEBUG
SubscribersSet::iterator iter = subs.find(pActor);
ASSERT_M( iter == subs.end(), "already subscribed" );
#endif
subs.insert( pActor );
}
void MessageManager::Unsubscribe( Actor* pActor, const CString& sMessage )
{
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
SubscribersSet::iterator iter = subs.find(pActor);
ASSERT( iter != subs.end() );
subs.erase( iter );
}
void MessageManager::Broadcast( const CString& sMessage )
{
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
FOREACHS_CONST( Actor*, subs, p )
{
(*p)->PlayCommand( sMessage );
}
}
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+56
View File
@@ -0,0 +1,56 @@
/* MessageManager - Control lights. */
#ifndef MessageManager_H
#define MessageManager_H
#include <set>
#include <map>
class Actor;
struct XNode;
class MessageManager
{
public:
MessageManager();
~MessageManager();
void Subscribe( Actor* pActor, const CString& sMessage );
void Unsubscribe( Actor* pActor, const CString& sMessage );
void Broadcast( const CString& sMessage );
private:
typedef set<Actor*> SubscribersSet;
map<CString,SubscribersSet> m_MessageToSubscribers;
};
extern MessageManager* MESSAGEMAN; // global and accessable from anywhere in our program
#endif
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+6 -3
View File
@@ -62,6 +62,7 @@
#include "ModelManager.h"
#include "CryptManager.h"
#include "NetworkSyncManager.h"
#include "MessageManager.h"
#if defined(XBOX)
#include "Archutils/Xbox/VirtualMemory.h"
@@ -177,7 +178,8 @@ void ShutdownGame()
SOUNDMAN->Shutdown();
SAFE_DELETE( SCREENMAN );
SAFE_DELETE( NSMAN );
SAFE_DELETE( MESSAGEMAN );
SAFE_DELETE( NSMAN );
/* Delete INPUTMAN before the other INPUTFILTER handlers, or an input
* driver may try to send a message to INPUTFILTER after we delete it. */
SAFE_DELETE( INPUTMAN );
@@ -1084,9 +1086,10 @@ int main(int argc, char* argv[])
PROFILEMAN = new ProfileManager;
PROFILEMAN->Init(); // must load after SONGMAN
UNLOCKMAN = new UnlockSystem;
NSMAN = new NetworkSyncManager( loading_window );
NSMAN = new NetworkSyncManager( loading_window );
MESSAGEMAN = new MessageManager;
delete loading_window; // destroy this before init'ing Display
SAFE_DELETE( loading_window ); // destroy this before init'ing Display
DISPLAY = CreateDisplay();
+10 -2
View File
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -99,7 +99,7 @@ IntDir=.\../Release6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -3012,6 +3012,14 @@ SOURCE=.\MemoryCardManager.h
# End Source File
# Begin Source File
SOURCE=.\MessageManager.cpp
# End Source File
# Begin Source File
SOURCE=.\MessageManager.h
# End Source File
# Begin Source File
SOURCE=.\NetworkSyncManager.cpp
# End Source File
# Begin Source File
+6
View File
@@ -2346,6 +2346,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="MemoryCardManager.h">
</File>
<File
RelativePath="MessageManager.cpp">
</File>
<File
RelativePath="MessageManager.h">
</File>
<File
RelativePath="NetworkSyncManager.cpp">
</File>