os/boardsupport/haitest/bspsvs/suite/common/inc/DataWrapperBase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/common/inc/DataWrapperBase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,115 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 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 +#if (!defined __DATA_WRAPPER_BASE__)
    1.23 +#define __DATA_WRAPPER_BASE__
    1.24 +
    1.25 +//	EPOC includes
    1.26 +#include <datawrapper.h>
    1.27 +#define SECS_TO_MS(x)  (x*1000000)
    1.28 +
    1.29 +typedef TBuf<KTEFMaxNameLength>	TIniDataName;
    1.30 +
    1.31 +_LIT(KConsname,				"Test Console");
    1.32 +
    1.33 +#define	GETFROMCONFIGOPTIONAL(aType, aSectName, aKeyName, aResult, aLogMessage)	\
    1.34 +		if ( !Get##aType##FromConfig(aSectName, aKeyName, aResult) )	\
    1.35 +			{															\
    1.36 +			WARN_PRINTF3(aLogMessage, &aKeyName, aResult);				\
    1.37 +			}
    1.38 +
    1.39 +#define	GETFROMCONFIGMANDATORY(aType, aSectName, aKeyName, aResult, aLogMessage, aDataOk)	\
    1.40 +		if ( !Get##aType##FromConfig(aSectName, aKeyName, aResult) )	\
    1.41 +			{															\
    1.42 +			ERR_PRINTF2(aLogMessage, &aKeyName);						\
    1.43 +			SetBlockResult(EFail);										\
    1.44 +			aDataOk=EFalse;												\
    1.45 +			}
    1.46 +
    1.47 +#define	GETSTRINGFROMCONFIGOPTIONAL(aSectName, aKeyName, aResult, aLogMessage)	\
    1.48 +		if ( !GetStringFromConfig(aSectName, aKeyName, aResult) )		\
    1.49 +			{															\
    1.50 +			WARN_PRINTF3(aLogMessage, &aKeyName, &aResult);				\
    1.51 +			}
    1.52 +
    1.53 +#define	GETSTRINGFROMCONFIGMANDATORY(aSectName, aKeyName, aResult, aLogMessage, aDataOk)	\
    1.54 +		if ( !GetStringFromConfig(aSectName, aKeyName, aResult) )		\
    1.55 +			{															\
    1.56 +			ERR_PRINTF2(aLogMessage, &aKeyName);						\
    1.57 +			SetBlockResult(EFail);										\
    1.58 +			aDataOk=EFalse;												\
    1.59 +			}
    1.60 +
    1.61 +class CDataWrapperBase : public CDataWrapper
    1.62 +	{
    1.63 +public:
    1.64 +	class TEnumEntryTable
    1.65 +		{
    1.66 +	public:
    1.67 +		const TDesC&	iString;
    1.68 +		TInt			iValue;
    1.69 +		};
    1.70 +
    1.71 +public:
    1.72 +	TBool					GetBoolFromConfig(const TDesC& aSectName,const TDesC& aKeyName,TBool& aResult);
    1.73 +	TBool					GetIntFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
    1.74 +	TBool					GetStringFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult);
    1.75 +	TBool					GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
    1.76 +	TBool					GetUintFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint& aResult);
    1.77 +	TBool					GetPointFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPoint& aResult);
    1.78 +	TBool					GetRectFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TRect& aResult);
    1.79 +	TBool					GetSizeFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TSize& aResult);
    1.80 +	TBool					GetEnumFromConfig(const TDesC& aSectName, const TDesC& aKeyName, const TEnumEntryTable* aTable, TInt& aResult);
    1.81 +	TBool					GetOrFromConfig(const TDesC& aSectName, const TDesC& aKeyName, const TEnumEntryTable* aTable, TUint& aResult);
    1.82 +	TBool 					GetUint8FromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint8& aResult);
    1.83 +	void 					Timedelay(TInt aTimeoutInSecs);
    1.84 +	virtual void			InitialiseL();
    1.85 +	inline RFs&				FileServer();
    1.86 +	inline CConsoleBase*	GetConsoleL();
    1.87 +	TBool					TranslateEnumToString(CDataWrapper& aDataWrapper, const TDesC& aEnum, const TInt aValue, TDesC& aTrasnaltion);
    1.88 +	TBool					TranslateNumberToEnumStringL(CDataWrapper& aDataWrapper, const TDesC& aSection, const TInt aValue, TDes& aTranslation);
    1.89 +	void 					PromptMessageL(const TDesC& aMsg,const TInt aDelayMiliSec,TKeyCode& aKeyCode);
    1.90 +	virtual TBool			DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
    1.91 +
    1.92 +protected:
    1.93 +	CDataWrapperBase();
    1.94 +	virtual ~CDataWrapperBase();
    1.95 +
    1.96 +	TBool	GetCommandStringParameter(const TDesC& aParameterName, const TDesC& aSection, TPtrC& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    1.97 +	TBool	GetCommandIntParameter(const TDesC& aParameterName, const TDesC& aSection, TInt& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    1.98 +	TBool	GetCommandBoolParameter(const TDesC& aParameterName, const TDesC& aSection, TBool& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    1.99 +
   1.100 +private:
   1.101 +	TBool	ProcessString(const TDesC& aStr, TUint& aResult, const TEnumEntryTable* aTable);
   1.102 +	TBool	ProcessEntry(const TDesC& aStr, TUint& aResult, const TEnumEntryTable* aTable);
   1.103 +	TBool 	ProcessEnumList(CDataWrapper& aDataWrapper,	const TDesC& aStr, const TDesC& aEnum, const TUint& aValue, TDes& aTranslation);
   1.104 +	TBool	GetCommandStringParameterL(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult);
   1.105 +	TBool 	KeyCheck();
   1.106 +	void 	DoCmdUtilityPromptMessageL(const TDesC& aSection);
   1.107 +
   1.108 +private:
   1.109 +	// Included ini files
   1.110 +	RPointerArray<CIniData>	iInclude;
   1.111 +	RPointerArray<HBufC>	iBuffer;
   1.112 +	RFs                     iFs;
   1.113 +	RTimer					iTimer;
   1.114 +	};
   1.115 +
   1.116 +#include "DataWrapperBase.inl"
   1.117 +
   1.118 +#endif /* __DATA_WRAPPER_BASE__ */