1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/utilitylibraries/libutils/tsrc/inc/commonframework.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,65 @@
1.4 +/*
1.5 +* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +#ifndef __CommonFramework_H
1.25 +#define __CommonFramework_H
1.26 +
1.27 +#include <e32base.h>
1.28 +#include <e32cons.h>
1.29 +
1.30 +_LIT(KTxtEPOC32EX,"EXAMPLES");
1.31 +_LIT(KTxtExampleCode,"Symbian OS Example Code");
1.32 +_LIT(KFormatFailed,"failed: leave code=%d");
1.33 +_LIT(KTxtOK,"ok");
1.34 +_LIT(KTxtPressAnyKey," [press any key]");
1.35 +
1.36 +// public
1.37 +LOCAL_D CConsoleBase* console; // write all your messages to this
1.38 +LOCAL_C void doExampleL(); // code this function for the real example
1.39 +
1.40 +// private
1.41 +LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
1.42 +
1.43 +GLDEF_C TInt E32Main() // main function called by E32
1.44 + {
1.45 + __UHEAP_MARK;
1.46 + CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
1.47 + TRAPD(error,callExampleL()); // more initialization, then do example
1.48 + __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
1.49 + delete cleanup; // destroy clean-up stack
1.50 + __UHEAP_MARKEND;
1.51 + return 0; // and return
1.52 + }
1.53 +
1.54 +LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
1.55 + {
1.56 + console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
1.57 + CleanupStack::PushL(console);
1.58 + TRAPD(error,doExampleL()); // perform example function
1.59 + if (error)
1.60 + console->Printf(KFormatFailed, error);
1.61 + else
1.62 + console->Printf(KTxtOK);
1.63 + console->Printf(KTxtPressAnyKey);
1.64 + console->Getch(); // get and ignore character
1.65 + CleanupStack::PopAndDestroy(); // close console
1.66 + }
1.67 +
1.68 +#endif