sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // The implementation of the accessor class upon the CDataLogger sl@0: // sl@0: // sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: _LIT(KTDataLogger_DumpName,"C:\\System\\Data\\Logs\\TDataLogger_StateDump.bin"); sl@0: sl@0: inline TInt TDataLogger_StateAccessor::InvariantTest(TAny* aTestObject) sl@0: { sl@0: if(aTestObject) sl@0: { sl@0: CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject); sl@0: if( theDataLogger->iLogOutput == NULL || sl@0: theDataLogger->iReportOutput == NULL) sl@0: return KTestBedFailedInvariant; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline TInt TDataLogger_StateAccessor::Internalize(TAny* aTestObject) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(aTestObject != NULL) sl@0: { sl@0: CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject); sl@0: TRAP(error,InternalizeL(theDataLogger)); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: inline TInt TDataLogger_StateAccessor::Externalize(TAny* aTestObject) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(aTestObject != NULL) sl@0: { sl@0: CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject); sl@0: TRAP(error,ExternalizeL(theDataLogger)); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: inline void TDataLogger_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CDataLogger* /* aLoadManager */) sl@0: { sl@0: // There is nothing to restore sl@0: } sl@0: sl@0: inline void TDataLogger_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CDataLogger* /* aLoadManager */) sl@0: { sl@0: // There is nothing to persist sl@0: } sl@0: sl@0: // internal helpers sl@0: inline void TDataLogger_StateAccessor::InternalizeL(CDataLogger* aDataLogger) sl@0: { sl@0: // Read in the dumped data sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: // Read the object dump sl@0: TParse filename; sl@0: filename.Set(KTDataLogger_DumpName(),NULL,NULL); sl@0: RFileReadStream stream; sl@0: User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead)); sl@0: CleanupClosePushL(stream); sl@0: InternalizeL(stream, aDataLogger); sl@0: CleanupStack::PopAndDestroy(2); // stream & fs sl@0: } sl@0: sl@0: inline void TDataLogger_StateAccessor::ExternalizeL(CDataLogger* aDataLogger) sl@0: { sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: // Write out the object dump sl@0: TParse filename; sl@0: filename.Set(KTDataLogger_DumpName(),NULL,NULL); sl@0: RFileWriteStream stream; sl@0: User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite)); sl@0: CleanupClosePushL(stream); sl@0: ExternalizeL(stream, aDataLogger); sl@0: CleanupStack::PopAndDestroy(2); // stream & fs sl@0: } sl@0: