www.pudn.com > symbianex.rar > Commonframework.h


// 
// Copyright (c) 2005 NEUSOFT Institute of inforamtion technology ChenDu. 
// All rights reserved. 
// 
// CommonFramework.h 
// the common framework for all the program 
// 
// Version 1.0 
// by YangZongde 
// 2005-9-28 
 
#ifndef __CommonFramework_H				//compile pretreatment 
#define __CommonFramework_H 
 
#include 					//inclde the base library 
#include  
_LIT(KTxtEPOC32EX,"EXAMPLE"); 
_LIT(KTxtExampleCode, "EXAMPLE"); 
_LIT(KFormatFailed,"failed:leave code=%d"); 
_LIT(KTxtOK,"OK"); 
_LIT(KTxtPressAnyKey,"[press any key]"); 
 
//public 
LOCAL_D CConsoleBase* console;				//declare the variable 
LOCAL_C void doExampleL();				//declare the function 
 
//private 
LOCAL_C void callExampleL(); 
 
GLDEF_C TInt E32Main()					//the entry of program 
{ 
	__UHEAP_MARK;					//heap check beginner 
	CTrapCleanup* cleanup=CTrapCleanup::New();	//the cleanup 
	TRAPD(error,callExampleL());			//trap if error 
	__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));	//if error=1 ,invoke the panic 
	delete cleanup;					//delete  
	__UHEAP_MARKEND;				//heap checkend,if error,invoke the panic 
	return 0; 
} 
 
LOCAL_C void callExampleL() 
{ 
	console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)); 
	CleanupStack::PushL(console);			//pushl the pointer to stack 
	TRAPD(error,doExampleL());			//trap if error 
	if(error) 
		console->Printf(KFormatFailed,error); 
	else 
		console->Printf(KTxtOK); 
	console->Printf(KTxtPressAnyKey); 
	console->Getch();				//wait user press any key 
	CleanupStack::PopAndDestroy(console);		 
} 
 
#endif