mmfenh/advancedaudiocontroller/tsrc/advancedaudiocontrollertestmodule/ActiveScheduledTestModule/src/OutputPrinter.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Active Scheduler Test Module
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "OutputPrinter.h"
       
    20 #include <StifTestModule.h>
       
    21 #include "TestModuleConstants.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 // None
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES
       
    27 // None
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 // None
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 // None
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 // None
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 // None
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS =======================================
       
    48 // None
       
    49 
       
    50 
       
    51 /*-------------------------------------------------------------------------------
       
    52 
       
    53     DESCRIPTION
       
    54 
       
    55     This module contains the implementation of OutputPrinter class
       
    56 	member functions.
       
    57 
       
    58 -------------------------------------------------------------------------------*/
       
    59 
       
    60 // ================= MEMBER FUNCTIONS =========================================
       
    61 
       
    62 COutputPrinter::COutputPrinter(CTestModuleBase *aTestModule, CStifLogger *aLogger, const TDesC &aConsoleTraceDescription, const TDesC &aTracePrefix, TInt aPrintPriority)
       
    63 : iPrintPriority(aPrintPriority), iConsoleTrace(aConsoleTraceDescription), iRDebugTracePrefix(aTracePrefix), iOutLogger(aLogger), iTestModule(aTestModule)
       
    64 {}
       
    65 
       
    66 /*	Sets the CStifLogger object to output data to
       
    67 	Returns the previos object used.
       
    68 	Note that COutputPrinter does not own the CStifLogger object and thus does not delete it
       
    69 */
       
    70 CStifLogger *COutputPrinter::SetLogger(CStifLogger *aNewLogger)
       
    71 	{
       
    72 	CStifLogger *oldLogger = iOutLogger;
       
    73 	iOutLogger = aNewLogger;
       
    74 	return oldLogger;
       
    75 	}
       
    76 
       
    77 CTestModuleBase *COutputPrinter::SetTestModule(CTestModuleBase *aNewTestModule)
       
    78 	{
       
    79 	CTestModuleBase *oldTestModule = iTestModule;
       
    80 	iTestModule = aNewTestModule;
       
    81 	return oldTestModule;
       
    82 	}
       
    83 
       
    84 void COutputPrinter::Echo(const TDesC &aMessage)
       
    85 	{
       
    86 	//TestModuleIf().Printf(iPrintPriority, iConsoleTrace, aMessage);
       
    87 	if (iTestModule)
       
    88 		{
       
    89 		iTestModule->TestModuleIf().Printf(iPrintPriority, iConsoleTrace, aMessage);
       
    90 		}
       
    91 	if (iOutLogger)
       
    92 		{
       
    93 		iOutLogger->Log(aMessage);
       
    94 		}
       
    95 	#ifdef _DEBUG
       
    96 	TBuf<KMaxMessageLength> debugMessage;
       
    97 	debugMessage = iRDebugTracePrefix;
       
    98 	//debugMessage+= KDefaultTextSeparator;
       
    99 	debugMessage+= aMessage;
       
   100 	RDebug::Print(debugMessage);
       
   101 	#endif
       
   102 	}
       
   103 
       
   104 void COutputPrinter::Echo(const TDesC &aFormat, const TDesC &aMessage)
       
   105 	{
       
   106 	TBuf<KMaxMessageLength> message;
       
   107 	message.Format(aFormat, &aMessage);
       
   108 	Echo(message);
       
   109 	}
       
   110 
       
   111 template<class T> void COutputPrinter::Echo(const TDesC &aFormat, T aMessage)
       
   112 	{
       
   113 	TBuf<KMaxMessageLength> message;
       
   114 	message.Format(aFormat, aMessage);
       
   115 	Echo(message);
       
   116 	}
       
   117 
       
   118 void COutputPrinter::Printf(TRefByValue<const TDesC> aLogInfo, ...)
       
   119 	{
       
   120     VA_LIST list;
       
   121     VA_START( list, aLogInfo );
       
   122 	TBuf<KMaxMessageLength> logInfo;
       
   123     //// Create overflow handler. If the log information size is over the
       
   124     //// KMaxLogData rest of the information will cut.
       
   125     //TDesOverflowHandler overFlowHandler( this, 1 );
       
   126 
       
   127     // Parse parameters
       
   128     logInfo.AppendFormatList( aLogInfo, list);
       
   129 	Echo(logInfo);
       
   130 	}