kerneltest/sdiotest/source/sdio_io.h
branchRCL_3
changeset 294 039a3e647356
parent 268 345b1ca54e88
child 295 5460f47b94ad
equal deleted inserted replaced
268:345b1ca54e88 294:039a3e647356
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // LDD for testing SDIO functions
       
    15 // 
       
    16 //
       
    17 
       
    18 #if !defined(__SDIO_IO_H__)
       
    19 #define __SDIO_IO_H__
       
    20 
       
    21 #include "tdisplay.h"
       
    22 
       
    23 /**
       
    24 Macro to format a variable length number of parameters into the iText member variable.
       
    25 
       
    26 @param c The format string
       
    27 
       
    28 @internal
       
    29 @test
       
    30 */
       
    31 #define FORMAT_TEXT(c) VA_LIST list; \
       
    32 	VA_START(list, c); \
       
    33 	FormatText(c, list); \
       
    34 	VA_END(list)
       
    35 
       
    36 class CIOBase : public CBase
       
    37 /**
       
    38 Base class to provide input/output facilities. Uses the function signatures from THexDisplay, 
       
    39 with dummy implementation.
       
    40 
       
    41 @internal
       
    42 @test
       
    43 */
       
    44 	{
       
    45 public:
       
    46 
       
    47 #if defined(_UNICODE)
       
    48 	class TIOOverflowHandler : public TDes16Overflow
       
    49 	/**
       
    50 	Base class to handle any logging overflows. 
       
    51 
       
    52 	@internal
       
    53 	@test
       
    54 	*/
       
    55 		{
       
    56 		public:
       
    57 			/**
       
    58 			Handle the overflow. 
       
    59 
       
    60 			@param aDes The descriptor at its maximum length.
       
    61 			
       
    62 			@internal
       
    63 			@test
       
    64 			*/
       
    65 			virtual void Overflow(TDes16 &aDes);
       
    66 		};
       
    67 #else
       
    68 	class TIOOverflowHandler : public TDes8Overflow
       
    69 	/**
       
    70 	Base class to handle any logging overflows. 
       
    71 
       
    72 	@internal
       
    73 	@test
       
    74 	*/
       
    75 		{
       
    76 		public:
       
    77 			/**
       
    78 			Handle the overflow. 
       
    79 
       
    80 			@param aDes The descriptor at its maximum length.
       
    81 			
       
    82 			@internal
       
    83 			@test
       
    84 			*/
       
    85 			virtual void Overflow(TDes8 &aDes);
       
    86 		};
       
    87 #endif
       
    88 	
       
    89 	/**
       
    90 	Constructor. 
       
    91 
       
    92 	@internal
       
    93 	@test
       
    94 	*/
       
    95 	CIOBase() {};
       
    96 
       
    97 	/**
       
    98 	Destructor. 
       
    99 
       
   100 	@internal
       
   101 	@test
       
   102 	*/
       
   103 	~CIOBase() {};
       
   104 
       
   105 	/**
       
   106 	Create the underlying resource. 
       
   107 
       
   108 	@param aName The name for the tests.
       
   109 	
       
   110 	@internal
       
   111 	@test
       
   112 	*/
       
   113 	virtual void CreateL(TPtrC aName) {};
       
   114 
       
   115 	/**
       
   116 	Provide a heading for the next test. 
       
   117 
       
   118 	@param aFmt The heading format.
       
   119 	
       
   120 	@internal
       
   121 	@test
       
   122 	*/
       
   123 	void Heading(TRefByValue<const TDesC> aFmt,...);
       
   124 
       
   125 	/**
       
   126 	Provide some instructions. 
       
   127 
       
   128 	@param aTopLine Whether to start from the top.
       
   129 	@param aFmt The formmatted text..
       
   130 	
       
   131 	@internal
       
   132 	@test
       
   133 	*/
       
   134 	void Instructions(TBool aTopLine, TRefByValue<const TDesC> aFmt,...);
       
   135 
       
   136 	/**
       
   137 	Print formatted output. 
       
   138 
       
   139 	@param aFmt The formmatted text.
       
   140 	
       
   141 	@internal
       
   142 	@test
       
   143 	*/
       
   144 	void Printf(TRefByValue<const TDesC> aFmt,...);
       
   145 
       
   146 	/**
       
   147 	Report an error. 
       
   148 
       
   149 	@param aErrText The heading format.
       
   150 	@param aErr The error code.
       
   151 	
       
   152 	@internal
       
   153 	@test
       
   154 	*/
       
   155 	virtual void ReportError(TPtrC aErrText, TInt aErr = KErrNone) {};
       
   156 
       
   157 	/**
       
   158 	Move to the curser to the start of the line. 
       
   159 	
       
   160 	@internal
       
   161 	@test
       
   162 	*/
       
   163 	virtual void CurserToDataStart() {};
       
   164 
       
   165 	/**
       
   166 	Get a character from the input stream.
       
   167 	
       
   168 	@return The keycode of the input character. 
       
   169 	
       
   170 	@internal
       
   171 	@test
       
   172 	*/
       
   173 	virtual TKeyCode Getch() { return EKeyNull; };
       
   174 	
       
   175 	/**
       
   176 	Clear the screen.
       
   177 		
       
   178 	@internal
       
   179 	@test
       
   180 	*/
       
   181 	virtual void ClearScreen() {};
       
   182 	
       
   183 protected:
       
   184 	virtual void DoHeading() {};
       
   185 	virtual void DoInstructions(TBool aTopLine) {};
       
   186 	virtual void DoPrintf() {};
       
   187 	void FormatText(TRefByValue<const TDesC> aFmt, VA_LIST aList);
       
   188 
       
   189 protected:	
       
   190 	/** A temporary buffer for formatting text */
       
   191 	TBuf<512>			iText;
       
   192 	/** An overflow handler */
       
   193 	TIOOverflowHandler	iOverflowHandler;
       
   194 	};
       
   195 
       
   196 class CIOConsole : public CIOBase
       
   197 /**
       
   198 Class to provide input/output facilities using THexDisplay.
       
   199 
       
   200 @internal
       
   201 @test
       
   202 */
       
   203 	{
       
   204 public:
       
   205 	/**
       
   206 	Constructor. 
       
   207 
       
   208 	@internal
       
   209 	@test
       
   210 	*/
       
   211 	CIOConsole() {};
       
   212 
       
   213 	/**
       
   214 	Destructor. 
       
   215 
       
   216 	@internal
       
   217 	@test
       
   218 	*/
       
   219 	~CIOConsole();
       
   220 	
       
   221 	/**
       
   222 	Create the underlying resource. 
       
   223 
       
   224 	@param aName The name for the tests.
       
   225 	
       
   226 	@internal
       
   227 	@test
       
   228 	*/
       
   229 	virtual void CreateL(TPtrC aName);
       
   230 
       
   231 	/**
       
   232 	Report an error. 
       
   233 
       
   234 	@param aErrText The heading format.
       
   235 	@param aErr The error code.
       
   236 	
       
   237 	@internal
       
   238 	@test
       
   239 	*/
       
   240 	virtual void ReportError(TPtrC aErrText, TInt aErr=KErrNone);
       
   241 
       
   242 	/**
       
   243 	Move to the curser to the start of the line. 
       
   244 	
       
   245 	@internal
       
   246 	@test
       
   247 	*/
       
   248 	virtual void CurserToDataStart();
       
   249 
       
   250 	/**
       
   251 	Get a character from the input stream.
       
   252 	
       
   253 	@return The keycode of the input character. 
       
   254 	
       
   255 	@internal
       
   256 	@test
       
   257 	*/
       
   258 	virtual TKeyCode Getch();
       
   259 
       
   260 	/**
       
   261 	Clear the screen.
       
   262 		
       
   263 	@internal
       
   264 	@test
       
   265 	*/
       
   266 	virtual void ClearScreen();	
       
   267 	
       
   268 protected:
       
   269 	virtual void DoHeading();
       
   270 	virtual void DoInstructions(TBool aTopLine);
       
   271 	virtual void DoPrintf();
       
   272 
       
   273 private:
       
   274 	THexDisplay	iDisplay;
       
   275 	};
       
   276 
       
   277 class CIORDebug : public CIOBase
       
   278 /**
       
   279 Class to provide input/output facilities using RDebug.
       
   280 
       
   281 @internal
       
   282 @test
       
   283 */
       
   284 	{
       
   285 public:
       
   286 	/**
       
   287 	Constructor. 
       
   288 
       
   289 	@internal
       
   290 	@test
       
   291 	*/
       
   292 	CIORDebug() {};
       
   293 
       
   294 	/**
       
   295 	Destructor. 
       
   296 
       
   297 	@internal
       
   298 	@test
       
   299 	*/
       
   300 	~CIORDebug() {};
       
   301 	
       
   302 	/**
       
   303 	Create the underlying resource. 
       
   304 
       
   305 	@param aName The name for the tests.
       
   306 	
       
   307 	@internal
       
   308 	@test
       
   309 	*/
       
   310 	virtual void CreateL(TPtrC aName);
       
   311 
       
   312 	/**
       
   313 	Report an error. 
       
   314 
       
   315 	@param aErrText The heading format.
       
   316 	@param aErr The error code.
       
   317 	
       
   318 	@internal
       
   319 	@test
       
   320 	*/
       
   321 	virtual void ReportError(TPtrC aErrText, TInt aErr=KErrNone);
       
   322 	
       
   323 	/**
       
   324 	Clear the screen.
       
   325 	
       
   326 	@internal
       
   327 	@test
       
   328 	*/
       
   329 	virtual void ClearScreen();	
       
   330 
       
   331 protected:
       
   332 	virtual void DoHeading();
       
   333 	virtual void DoPrintf();
       
   334 	};
       
   335 
       
   336 #endif // __SDIO_IO_H__
       
   337