|
Nokia N97 SDK Example Applications Guide |
00001 /** \file CommonFramework.h */ 00002 00003 // 00004 // Copyright (c) 2000 Symbian Ltd. All rights reserved. 00005 // 00006 00007 #ifndef __CommonFramework_H 00008 #define __CommonFramework_H 00009 00010 #include <e32base.h> 00011 #include <e32cons.h> 00012 00013 _LIT(KTxtEPOC32EX,"EXAMPLES"); 00014 _LIT(KTxtExampleCode,"Symbian OS Example Code"); 00015 _LIT(KFormatFailed,"failed: leave code=%d"); 00016 _LIT(KTxtOK,"ok"); 00017 _LIT(KTxtPressAnyKey,"\n[press any key]\n"); 00018 00019 // public 00020 LOCAL_D CConsoleBase* console; // write all your messages to this 00021 LOCAL_C void doExampleL(); // code this function for the real example 00022 00023 // private 00024 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example 00025 00026 /** \fn TInt E32Main() 00027 * 00028 * main function called by E32. 00029 * Creates clean-up stack and calls example initialization function 00030 */ 00031 GLDEF_C TInt E32Main() 00032 { 00033 __UHEAP_MARK; 00034 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack 00035 TRAPD(error,callExampleL()); // more initialization, then do example 00036 __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error)); 00037 delete cleanup; // destroy clean-up stack 00038 __UHEAP_MARKEND; 00039 return 0; // and return 00040 } 00041 00042 /** \fn LOCAL_C void callExampleL() 00043 * 00044 * creates console and calls example code under cleanup stack 00045 */ 00046 LOCAL_C void callExampleL() 00047 { 00048 console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)); 00049 CleanupStack::PushL(console); 00050 TRAPD(error,doExampleL()); // perform example function 00051 if (error) 00052 console->Printf(KFormatFailed, error); 00053 else 00054 console->Printf(KTxtOK); 00055 console->Printf(KTxtPressAnyKey); 00056 console->Getch(); // get and ignore character 00057 CleanupStack::PopAndDestroy(); // close console 00058 } 00059 00060 #endif
|
© Nokia 2009 |