// how to create a global singleton object
const TInt KMarkTlsHandle = 0xC0FFEE;
class CYourClass: public CBase
{
public:
CYourClass(){};
void ConstructL(){};
~CYourClass();
};
CYourClass::~CYourClass()
{
//release TLS
UserSvr::DllFreeTls(KMarkTlsHandle);
}
//how to create a global singleton object
void CMarkEComWrapper::DoCommandCreateSingletonObject()
{
TInt err = KErrNone;
//Get object from STL
CYourClass* iSingletonObject = static_cast
//if not, create one
if (!iSingletonObject)
{
iSingletonObject = new (ELeave) CYourClass;
CleanupStack::PushL(iSingletonObject);
iSingletonObject->ConstructL();
err = UserSvr::DllSetTls( KMarkTlsHandle, iSingletonObject );
CleanupStack::Pop(iSingletonObject);
}
delete iSingletonObject ;
iSingletonObject = 0;
}
how to create a global singleton object in exe Monday, January 11, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment