|
1 /* |
|
2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CommonFramework_H |
|
22 #define __CommonFramework_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32cons.h> |
|
26 |
|
27 _LIT(KTxtEPOC32EX,"EXAMPLES"); |
|
28 _LIT(KTxtExampleCode,"Symbian OS Example Code"); |
|
29 _LIT(KFormatFailed,"failed: leave code=%d"); |
|
30 _LIT(KTxtOK,"ok"); |
|
31 _LIT(KTxtPressAnyKey," [press any key]"); |
|
32 |
|
33 // public |
|
34 LOCAL_D CConsoleBase* console; // write all your messages to this |
|
35 LOCAL_C void doExampleL(); // code this function for the real example |
|
36 |
|
37 // private |
|
38 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example |
|
39 |
|
40 GLDEF_C TInt E32Main() // main function called by E32 |
|
41 { |
|
42 __UHEAP_MARK; |
|
43 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
44 TRAPD(error,callExampleL()); // more initialization, then do example |
|
45 __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error)); |
|
46 delete cleanup; // destroy clean-up stack |
|
47 __UHEAP_MARKEND; |
|
48 return 0; // and return |
|
49 } |
|
50 |
|
51 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack |
|
52 { |
|
53 console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)); |
|
54 CleanupStack::PushL(console); |
|
55 TRAPD(error,doExampleL()); // perform example function |
|
56 if (error) |
|
57 console->Printf(KFormatFailed, error); |
|
58 else |
|
59 console->Printf(KTxtOK); |
|
60 console->Printf(KTxtPressAnyKey); |
|
61 console->Getch(); // get and ignore character |
|
62 CleanupStack::PopAndDestroy(); // close console |
|
63 } |
|
64 |
|
65 #endif |