os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionStateAccessor.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2001-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 CTransition
    15 // 
    16 //
    17 
    18 // ______________________________________________________________________________
    19 //
    20 _LIT(KTTransition_DumpName,"C:\\System\\Data\\Logs\\TTransition_StateDump.bin");
    21 
    22 inline TInt TTransition_StateAccessor::InvariantTest(TAny* aTestObject)
    23 	{
    24 	if(aTestObject)
    25 		{
    26 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    27 		if(theTransition->iTransitionId.Length() == 0)
    28 			return KErrArgument;
    29 		}
    30 	return KErrNone;
    31 	}
    32 
    33 inline TInt TTransition_StateAccessor::Internalize(TAny* aTestObject)
    34 	{
    35 	TInt error = KErrNone;
    36 	if(aTestObject != NULL)
    37 		{
    38 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    39 		TRAP(error,InternalizeL(theTransition));
    40 		}
    41 	return error;
    42 	}
    43 
    44 inline TInt TTransition_StateAccessor::Externalize(TAny* aTestObject)
    45 	{
    46 	TInt error = KErrNone;
    47 	if(aTestObject != NULL)
    48 		{
    49 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    50 		TRAP(error,ExternalizeL(theTransition));
    51 		}
    52 	return error;
    53 	}
    54 
    55 inline TBool TTransition_StateAccessor::IsRepeated(TAny* aTestObject) const
    56 	{
    57 	if(aTestObject != NULL)
    58 		{
    59 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    60 		return theTransition->iRepeatThis;
    61 		}
    62 	return EFalse;
    63 	}
    64 
    65 inline const TDesC* TTransition_StateAccessor::TransitionId(TAny* aTestObject) const
    66 	{
    67 	if(aTestObject != NULL)
    68 		{
    69 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    70 		return &(theTransition->iTransitionId);
    71 		}
    72 	return NULL;
    73 	}
    74 
    75 inline const TTransitionInfo* TTransition_StateAccessor::TransitionInfo(TAny* aTestObject) const
    76 	{
    77 	if(aTestObject != NULL)
    78 		{
    79 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    80 		return &(theTransition->iTransitionInfo);
    81 		}
    82 	return NULL;
    83 	}
    84 
    85 inline TBool TTransition_StateAccessor::BlockingFlag(TAny* aTestObject) const
    86 	{
    87 	if(aTestObject != NULL)
    88 		{
    89 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
    90 		return theTransition->iBlockingTransition;
    91 		}
    92 	return EFalse;
    93 	}
    94 
    95 inline TInt TTransition_StateAccessor::ErrorCode(TAny* aTestObject) const
    96 	{
    97 	if(aTestObject != NULL)
    98 		{
    99 		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
   100 		return theTransition->iLeaveError;
   101 		}
   102 	return EFalse;
   103 	}
   104 
   105 inline TRequestStatus TTransition_StateAccessor::Status(const TAny* aTestObject) const
   106 	{
   107 	TRequestStatus status;
   108 	Mem::FillZ(&status, sizeof(status));
   109 	if(aTestObject != NULL)
   110 		{
   111 		status = (reinterpret_cast <const CTransition*> (aTestObject))->iStatus;
   112 		}
   113 	return status;
   114 	}
   115 
   116 inline void TTransition_StateAccessor::InternalizeL(RFileReadStream& aStream, CTransition* aTransition)
   117 	{
   118 	aTransition->iRepeatThis				= aStream.ReadInt32L();
   119 	aTransition->iTransitionFinished		= aStream.ReadInt32L();
   120 	aTransition->iLeaveError				= aStream.ReadInt32L();
   121 	aTransition->iBlockingTransition		= aStream.ReadInt32L();
   122 	TPckg<TTransitionInfo> info(aTransition->iTransitionInfo);
   123 	aStream.ReadL(info);
   124 	}
   125 
   126 inline void TTransition_StateAccessor::ExternalizeL(RFileWriteStream& aStream, CTransition* aTransition)
   127 	{
   128 	aStream.WriteInt32L(aTransition->iRepeatThis);
   129 	aStream.WriteInt32L(aTransition->iTransitionFinished);
   130 	aStream.WriteInt32L(aTransition->iLeaveError);
   131 	aStream.WriteInt32L(aTransition->iBlockingTransition);
   132 	TPckg<TTransitionInfo> info(aTransition->iTransitionInfo);
   133 	aStream.WriteL(info);
   134 	}
   135 
   136 // internal helpers
   137 inline void TTransition_StateAccessor::InternalizeL(CTransition* aTransition)
   138 	{
   139 	// Read in the dumped data
   140 	RFs fs;
   141 	User::LeaveIfError(fs.Connect());
   142 	CleanupClosePushL(fs);
   143 	// Read the object dump
   144 	TParse filename;
   145 	filename.Set(KTTransition_DumpName(),NULL,NULL);
   146 	RFileReadStream stream;
   147 	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
   148 	CleanupClosePushL(stream);
   149 	InternalizeL(stream, aTransition);
   150 	CleanupStack::PopAndDestroy(2);		// stream & fs
   151 	}
   152 
   153 inline void TTransition_StateAccessor::ExternalizeL(CTransition* aTransition)
   154 	{
   155 	RFs fs;
   156 	User::LeaveIfError(fs.Connect());
   157 	CleanupClosePushL(fs);
   158 	// Write out the object dump
   159 	TParse filename;
   160 	filename.Set(KTTransition_DumpName(),NULL,NULL);
   161 	RFileWriteStream stream;
   162 	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
   163 	CleanupClosePushL(stream);
   164 	ExternalizeL(stream, aTransition);
   165 	stream.CommitL();
   166 	CleanupStack::PopAndDestroy(2);		// stream & fs
   167 	}
   168