os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/DataLoggerTest/DataLoggerStateAccessor.inl
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The implementation of the accessor class upon the CDataLogger
18 // ______________________________________________________________________________
20 _LIT(KTDataLogger_DumpName,"C:\\System\\Data\\Logs\\TDataLogger_StateDump.bin");
22 inline TInt TDataLogger_StateAccessor::InvariantTest(TAny* aTestObject)
26 CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
27 if( theDataLogger->iLogOutput == NULL ||
28 theDataLogger->iReportOutput == NULL)
29 return KTestBedFailedInvariant;
34 inline TInt TDataLogger_StateAccessor::Internalize(TAny* aTestObject)
36 TInt error = KErrNone;
37 if(aTestObject != NULL)
39 CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
40 TRAP(error,InternalizeL(theDataLogger));
45 inline TInt TDataLogger_StateAccessor::Externalize(TAny* aTestObject)
47 TInt error = KErrNone;
48 if(aTestObject != NULL)
50 CDataLogger* theDataLogger = REINTERPRET_CAST(CDataLogger*, aTestObject);
51 TRAP(error,ExternalizeL(theDataLogger));
56 inline void TDataLogger_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CDataLogger* /* aLoadManager */)
58 // There is nothing to restore
61 inline void TDataLogger_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CDataLogger* /* aLoadManager */)
63 // There is nothing to persist
67 inline void TDataLogger_StateAccessor::InternalizeL(CDataLogger* aDataLogger)
69 // Read in the dumped data
71 User::LeaveIfError(fs.Connect());
72 CleanupClosePushL(fs);
73 // Read the object dump
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
83 inline void TDataLogger_StateAccessor::ExternalizeL(CDataLogger* aDataLogger)
86 User::LeaveIfError(fs.Connect());
87 CleanupClosePushL(fs);
88 // Write out the object dump
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