os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/DataLoggerTest/DataLoggerStateAccessor.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1997-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 "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 // The implementation of the accessor class upon the CDataLogger
    15 // 
    16 //
    17 
    18 // ______________________________________________________________________________
    19 //
    20 _LIT(KTDataLogger_DumpName,"C:\\System\\Data\\Logs\\TDataLogger_StateDump.bin");
    21 
    22 inline TInt TDataLogger_StateAccessor::InvariantTest(TAny* aTestObject)
    23 	{
    24 	if(aTestObject)
    25 		{
    26 		CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
    27 		if(	theDataLogger->iLogOutput == NULL || 
    28 			theDataLogger->iReportOutput == NULL)
    29 			return KTestBedFailedInvariant;
    30 		}
    31 	return KErrNone;
    32 	}
    33 
    34 inline TInt TDataLogger_StateAccessor::Internalize(TAny* aTestObject)
    35 	{
    36 	TInt error = KErrNone;
    37 	if(aTestObject != NULL)
    38 		{
    39 		CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
    40 		TRAP(error,InternalizeL(theDataLogger));
    41 		}
    42 	return error;
    43 	}
    44 
    45 inline TInt TDataLogger_StateAccessor::Externalize(TAny* aTestObject)
    46 	{
    47 	TInt error = KErrNone;
    48 	if(aTestObject != NULL)
    49 		{
    50 		CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
    51 		TRAP(error,ExternalizeL(theDataLogger));
    52 		}
    53 	return error;
    54 	}
    55 
    56 inline void TDataLogger_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CDataLogger* /* aLoadManager */)
    57 	{
    58 	// There is nothing to restore
    59 	}
    60 
    61 inline void TDataLogger_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CDataLogger* /* aLoadManager */)
    62 	{
    63 	// There is nothing to persist
    64 	}
    65 
    66 // internal helpers
    67 inline void TDataLogger_StateAccessor::InternalizeL(CDataLogger* aDataLogger)
    68 	{
    69 	// Read in the dumped data
    70 	RFs fs;
    71 	User::LeaveIfError(fs.Connect());
    72 	CleanupClosePushL(fs);
    73 	// Read the object dump
    74 	TParse filename;
    75 	filename.Set(KTDataLogger_DumpName(),NULL,NULL);
    76 	RFileReadStream stream;
    77 	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
    78 	CleanupClosePushL(stream);
    79 	InternalizeL(stream, aDataLogger);
    80 	CleanupStack::PopAndDestroy(2);	// stream & fs
    81 	}
    82 
    83 inline void TDataLogger_StateAccessor::ExternalizeL(CDataLogger* aDataLogger)
    84 	{
    85 	RFs fs;
    86 	User::LeaveIfError(fs.Connect());
    87 	CleanupClosePushL(fs);
    88 	// Write out the object dump
    89 	TParse filename;
    90 	filename.Set(KTDataLogger_DumpName(),NULL,NULL);
    91 	RFileWriteStream stream;
    92 	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
    93 	CleanupClosePushL(stream);
    94 	ExternalizeL(stream, aDataLogger);
    95 	CleanupStack::PopAndDestroy(2);	// stream & fs
    96 	}
    97