lowlevellibsandfws/pluginfw/Test_Bed/DefaultLogOutputTest/DefaultLogOutputStateAccessor.inl
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 CDefaultLogOutput
       
    15 // 
       
    16 //
       
    17 
       
    18 // ______________________________________________________________________________
       
    19 //
       
    20 _LIT(KTDefaultLogOutput_DumpName,"C:\\System\\Data\\Logs\\TDefaultLogOutput_StateDump.bin");
       
    21 
       
    22 inline TInt TDefaultLogOutput_StateAccessor::InvariantTest(TAny* aTestObject)
       
    23 	{
       
    24 	if(aTestObject)
       
    25 		{
       
    26 		// Nothing to do
       
    27 		}
       
    28 	return KErrNone;
       
    29 	}
       
    30 
       
    31 inline TInt TDefaultLogOutput_StateAccessor::Internalize(TAny* aTestObject)
       
    32 	{
       
    33 	TInt error = KErrNone;
       
    34 	if(aTestObject != NULL)
       
    35 		{
       
    36 		CDefaultLogOutput* theDefaultLogOutput = REINTERPRET_CAST(CDefaultLogOutput*, aTestObject);
       
    37 		TRAP(error,InternalizeL(theDefaultLogOutput));
       
    38 		}
       
    39 	return error;
       
    40 	}
       
    41 
       
    42 inline TInt TDefaultLogOutput_StateAccessor::Externalize(TAny* aTestObject)
       
    43 	{
       
    44 	TInt error = KErrNone;
       
    45 	if(aTestObject != NULL)
       
    46 		{
       
    47 		CDefaultLogOutput* theDefaultLogOutput = REINTERPRET_CAST(CDefaultLogOutput*, aTestObject);
       
    48 		TRAP(error,ExternalizeL(theDefaultLogOutput));
       
    49 		}
       
    50 	return error;
       
    51 	}
       
    52 
       
    53 inline void TDefaultLogOutput_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CDefaultLogOutput* /* aLoadManager */)
       
    54 	{
       
    55 	}
       
    56 
       
    57 inline void TDefaultLogOutput_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CDefaultLogOutput* /* aLoadManager */)
       
    58 	{
       
    59 	}
       
    60 
       
    61 // internal helpers
       
    62 inline void TDefaultLogOutput_StateAccessor::InternalizeL(CDefaultLogOutput* aDefaultLogOutput)
       
    63 	{
       
    64 	// Read in the dumped data
       
    65 	RFs fs;
       
    66 	User::LeaveIfError(fs.Connect());
       
    67 	CleanupClosePushL(fs);
       
    68 	// Read the object dump
       
    69 	TParse filename;
       
    70 	filename.Set(KTDefaultLogOutput_DumpName(),NULL,NULL);
       
    71 	RFileReadStream stream;
       
    72 	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
       
    73 	CleanupClosePushL(stream);
       
    74 	InternalizeL(stream, aDefaultLogOutput);
       
    75 	CleanupStack::PopAndDestroy(2);	// stream & fs
       
    76 	}
       
    77 
       
    78 inline void TDefaultLogOutput_StateAccessor::ExternalizeL(CDefaultLogOutput* aDefaultLogOutput)
       
    79 	{
       
    80 	RFs fs;
       
    81 	User::LeaveIfError(fs.Connect());
       
    82 	CleanupClosePushL(fs);
       
    83 	// Write out the object dump
       
    84 	TParse filename;
       
    85 	filename.Set(KTDefaultLogOutput_DumpName(),NULL,NULL);
       
    86 	RFileWriteStream stream;
       
    87 	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
       
    88 	CleanupClosePushL(stream);
       
    89 	ExternalizeL(stream, aDefaultLogOutput);
       
    90 	CleanupStack::PopAndDestroy(2);	// stream & fs
       
    91 	}
       
    92