47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// #2.1.2.11.1
|
|
#pragma once
|
|
|
|
class SGame;
|
|
class IContents;
|
|
struct SGameMessage;
|
|
struct TS_MESSAGE;
|
|
|
|
class SContentsManager
|
|
{
|
|
public:
|
|
SContentsManager( SGame* game );
|
|
~SContentsManager();
|
|
void process( DWORD time );
|
|
void ProcMsgAtStatic( SGameMessage* msg );
|
|
void sendMsg( const TS_MESSAGE& msg );
|
|
void sendInterfaceMsg( SGameMessage& msg );
|
|
template< typename T > T* acquire( const char* name )
|
|
{
|
|
IContents* found = _findContents( name );
|
|
if( !found )
|
|
found = new T( name, *this );
|
|
return static_cast< T* >( found );
|
|
}
|
|
void dispose( const char* name );
|
|
|
|
// don't use
|
|
void registerMsgObserver( const int msgId, IContents& contents );
|
|
void deregisterMsgObserver( const int msgId, IContents& contents );
|
|
|
|
private:
|
|
friend class IContents;
|
|
|
|
void disposeAll();
|
|
IContents* _findContents( const char* name );
|
|
void _addContents( const char* name, IContents& contents );
|
|
void _rmvContents( const char* name );
|
|
|
|
typedef std::vector< IContents* > ContentsChunk;
|
|
typedef std::map< const int, ContentsChunk* > MsgObserverMap;
|
|
typedef std::map< std::string, IContents* > ContentsMap;
|
|
|
|
SGame* mGame;
|
|
ContentsChunk mContents;
|
|
ContentsMap mContentsMap;
|
|
MsgObserverMap mMsgMap;
|
|
}; |