examples/SysLibs/CommonFramework/CommonFramework.h

00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 
00017 #ifndef __CommonFramework_H
00018 #define __CommonFramework_H
00019 
00020 #include <e32base.h>
00021 #include <e32cons.h>
00022 
00023 _LIT(KTxtEPOC32EX,"EXAMPLES");
00024 _LIT(KTxtExampleCode,"Symbian platform Example Code");
00025 _LIT(KFormatFailed,"failed: leave code=%d");
00026 _LIT(KTxtOK,"ok");
00027 _LIT(KTxtPressAnyKey," [press any key]");
00028 
00029 // public
00030 LOCAL_D CConsoleBase* console; // write all your messages to this
00031 LOCAL_C void doExampleL(); // code this function for the real example
00032 
00033 // private
00034 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
00035 
00036 GLDEF_C TInt E32Main() // main function called by E32
00037     {
00038         __UHEAP_MARK;
00039         CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
00040         TRAPD(error,callExampleL()); // more initialization, then do example
00041         __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
00042         delete cleanup; // destroy clean-up stack
00043         __UHEAP_MARKEND;
00044         return 0; // and return
00045     }
00046 
00047 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
00048     {
00049         console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
00050         CleanupStack::PushL(console);
00051         TRAPD(error,doExampleL()); // perform example function
00052         if (error)
00053                 console->Printf(KFormatFailed, error);
00054         else
00055                 console->Printf(KTxtOK);
00056         console->Printf(KTxtPressAnyKey);
00057         console->Getch(); // get and ignore character
00058         CleanupStack::PopAndDestroy(); // close console
00059     }
00060 
00061 #endif

Generated by  doxygen 1.6.2