globalstorage.cpp

来自「一个symbian 冒险游戏代码」· C++ 代码 · 共 53 行

CPP
53
字号
#include <lang/GlobalStorage.h>
#ifdef __SYMBIAN32__
#include <e32std.h>
#endif
#ifdef __SERIES60_3X__
#include <e32svr.h>
#endif
#include <string.h>
#include <config.h>


namespace lang
{


#ifndef __SYMBIAN32__
GlobalStorage GlobalStorage::sm_instance;
#elif defined(__SERIES60_3X__)
static GlobalStorage s_instance;
#endif


GlobalStorage::GlobalStorage()
{
	// a bit ugly but this class contains only regular pointers
	// and we don't want to end up forgetting to initialize some pointer
	memset( this, 0, sizeof(GlobalStorage) );
}

#ifdef __SYMBIAN32__
GlobalStorage& GlobalStorage::get()
{
#ifdef __SERIES60_3X__

	return s_instance;

#else

	GlobalStorage* gs = reinterpret_cast<GlobalStorage*>( Dll::Tls() );
	if ( !gs )
	{
		gs = new GlobalStorage;
		Dll::SetTls( gs );
	}
	return *gs;
		
#endif
}
#endif // __SYMBIAN32__


} // lang

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?