usbmgmt/usbmgrtest/t_acm_pub_sub/inc/CommonFramework.h
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 2000-2009 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 #ifndef __CommonFramework_H
       
    20 #define __CommonFramework_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32cons.h>
       
    24 
       
    25 _LIT(KTxtEPOC32EX,"EXAMPLES");
       
    26 _LIT(KTxtExampleCode,"Symbian OS Example Code");
       
    27 _LIT(KFormatFailed,"failed: leave code=%d");
       
    28 _LIT(KTxtOK,"ok");
       
    29 _LIT(KTxtPressAnyKey," [press any key]");
       
    30 
       
    31 // public
       
    32 LOCAL_D CConsoleBase* console; // write all your messages to this
       
    33 LOCAL_C void doExampleL(CConsoleBase*); // code this function for the real example
       
    34 
       
    35 // private
       
    36 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
       
    37 
       
    38 GLDEF_C TInt E32Main() // main function called by E32
       
    39     {
       
    40 	__UHEAP_MARK;
       
    41 	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
       
    42 	TRAPD(error,callExampleL()); // more initialization, then do example
       
    43 	__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
       
    44 	delete cleanup; // destroy clean-up stack
       
    45 	__UHEAP_MARKEND;
       
    46 	return 0; // and return
       
    47     }
       
    48 
       
    49 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
       
    50     {
       
    51 	console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
       
    52 	CleanupStack::PushL(console);
       
    53 	
       
    54 	TRAPD(error,doExampleL(console)); // perform example function
       
    55 		
       
    56 	if (error)
       
    57 		console->Printf(KFormatFailed, error);
       
    58 	else
       
    59 		console->Printf(KTxtOK);
       
    60 	
       
    61 	console->Printf(KTxtPressAnyKey);
       
    62 	console->Getch(); // get and ignore character
       
    63 	CleanupStack::PopAndDestroy(); // close console
       
    64     }
       
    65 
       
    66 #endif