os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionStateAccessor.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// The implementation of the accessor class upon the CTransition
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
// ______________________________________________________________________________
sl@0
    19
//
sl@0
    20
_LIT(KTTransition_DumpName,"C:\\System\\Data\\Logs\\TTransition_StateDump.bin");
sl@0
    21
sl@0
    22
inline TInt TTransition_StateAccessor::InvariantTest(TAny* aTestObject)
sl@0
    23
	{
sl@0
    24
	if(aTestObject)
sl@0
    25
		{
sl@0
    26
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    27
		if(theTransition->iTransitionId.Length() == 0)
sl@0
    28
			return KErrArgument;
sl@0
    29
		}
sl@0
    30
	return KErrNone;
sl@0
    31
	}
sl@0
    32
sl@0
    33
inline TInt TTransition_StateAccessor::Internalize(TAny* aTestObject)
sl@0
    34
	{
sl@0
    35
	TInt error = KErrNone;
sl@0
    36
	if(aTestObject != NULL)
sl@0
    37
		{
sl@0
    38
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    39
		TRAP(error,InternalizeL(theTransition));
sl@0
    40
		}
sl@0
    41
	return error;
sl@0
    42
	}
sl@0
    43
sl@0
    44
inline TInt TTransition_StateAccessor::Externalize(TAny* aTestObject)
sl@0
    45
	{
sl@0
    46
	TInt error = KErrNone;
sl@0
    47
	if(aTestObject != NULL)
sl@0
    48
		{
sl@0
    49
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    50
		TRAP(error,ExternalizeL(theTransition));
sl@0
    51
		}
sl@0
    52
	return error;
sl@0
    53
	}
sl@0
    54
sl@0
    55
inline TBool TTransition_StateAccessor::IsRepeated(TAny* aTestObject) const
sl@0
    56
	{
sl@0
    57
	if(aTestObject != NULL)
sl@0
    58
		{
sl@0
    59
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    60
		return theTransition->iRepeatThis;
sl@0
    61
		}
sl@0
    62
	return EFalse;
sl@0
    63
	}
sl@0
    64
sl@0
    65
inline const TDesC* TTransition_StateAccessor::TransitionId(TAny* aTestObject) const
sl@0
    66
	{
sl@0
    67
	if(aTestObject != NULL)
sl@0
    68
		{
sl@0
    69
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    70
		return &(theTransition->iTransitionId);
sl@0
    71
		}
sl@0
    72
	return NULL;
sl@0
    73
	}
sl@0
    74
sl@0
    75
inline const TTransitionInfo* TTransition_StateAccessor::TransitionInfo(TAny* aTestObject) const
sl@0
    76
	{
sl@0
    77
	if(aTestObject != NULL)
sl@0
    78
		{
sl@0
    79
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    80
		return &(theTransition->iTransitionInfo);
sl@0
    81
		}
sl@0
    82
	return NULL;
sl@0
    83
	}
sl@0
    84
sl@0
    85
inline TBool TTransition_StateAccessor::BlockingFlag(TAny* aTestObject) const
sl@0
    86
	{
sl@0
    87
	if(aTestObject != NULL)
sl@0
    88
		{
sl@0
    89
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
    90
		return theTransition->iBlockingTransition;
sl@0
    91
		}
sl@0
    92
	return EFalse;
sl@0
    93
	}
sl@0
    94
sl@0
    95
inline TInt TTransition_StateAccessor::ErrorCode(TAny* aTestObject) const
sl@0
    96
	{
sl@0
    97
	if(aTestObject != NULL)
sl@0
    98
		{
sl@0
    99
		CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
sl@0
   100
		return theTransition->iLeaveError;
sl@0
   101
		}
sl@0
   102
	return EFalse;
sl@0
   103
	}
sl@0
   104
sl@0
   105
inline TRequestStatus TTransition_StateAccessor::Status(const TAny* aTestObject) const
sl@0
   106
	{
sl@0
   107
	TRequestStatus status;
sl@0
   108
	Mem::FillZ(&status, sizeof(status));
sl@0
   109
	if(aTestObject != NULL)
sl@0
   110
		{
sl@0
   111
		status = (reinterpret_cast <const CTransition*> (aTestObject))->iStatus;
sl@0
   112
		}
sl@0
   113
	return status;
sl@0
   114
	}
sl@0
   115
sl@0
   116
inline void TTransition_StateAccessor::InternalizeL(RFileReadStream& aStream, CTransition* aTransition)
sl@0
   117
	{
sl@0
   118
	aTransition->iRepeatThis				= aStream.ReadInt32L();
sl@0
   119
	aTransition->iTransitionFinished		= aStream.ReadInt32L();
sl@0
   120
	aTransition->iLeaveError				= aStream.ReadInt32L();
sl@0
   121
	aTransition->iBlockingTransition		= aStream.ReadInt32L();
sl@0
   122
	TPckg<TTransitionInfo> info(aTransition->iTransitionInfo);
sl@0
   123
	aStream.ReadL(info);
sl@0
   124
	}
sl@0
   125
sl@0
   126
inline void TTransition_StateAccessor::ExternalizeL(RFileWriteStream& aStream, CTransition* aTransition)
sl@0
   127
	{
sl@0
   128
	aStream.WriteInt32L(aTransition->iRepeatThis);
sl@0
   129
	aStream.WriteInt32L(aTransition->iTransitionFinished);
sl@0
   130
	aStream.WriteInt32L(aTransition->iLeaveError);
sl@0
   131
	aStream.WriteInt32L(aTransition->iBlockingTransition);
sl@0
   132
	TPckg<TTransitionInfo> info(aTransition->iTransitionInfo);
sl@0
   133
	aStream.WriteL(info);
sl@0
   134
	}
sl@0
   135
sl@0
   136
// internal helpers
sl@0
   137
inline void TTransition_StateAccessor::InternalizeL(CTransition* aTransition)
sl@0
   138
	{
sl@0
   139
	// Read in the dumped data
sl@0
   140
	RFs fs;
sl@0
   141
	User::LeaveIfError(fs.Connect());
sl@0
   142
	CleanupClosePushL(fs);
sl@0
   143
	// Read the object dump
sl@0
   144
	TParse filename;
sl@0
   145
	filename.Set(KTTransition_DumpName(),NULL,NULL);
sl@0
   146
	RFileReadStream stream;
sl@0
   147
	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
sl@0
   148
	CleanupClosePushL(stream);
sl@0
   149
	InternalizeL(stream, aTransition);
sl@0
   150
	CleanupStack::PopAndDestroy(2);		// stream & fs
sl@0
   151
	}
sl@0
   152
sl@0
   153
inline void TTransition_StateAccessor::ExternalizeL(CTransition* aTransition)
sl@0
   154
	{
sl@0
   155
	RFs fs;
sl@0
   156
	User::LeaveIfError(fs.Connect());
sl@0
   157
	CleanupClosePushL(fs);
sl@0
   158
	// Write out the object dump
sl@0
   159
	TParse filename;
sl@0
   160
	filename.Set(KTTransition_DumpName(),NULL,NULL);
sl@0
   161
	RFileWriteStream stream;
sl@0
   162
	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
sl@0
   163
	CleanupClosePushL(stream);
sl@0
   164
	ExternalizeL(stream, aTransition);
sl@0
   165
	stream.CommitL();
sl@0
   166
	CleanupStack::PopAndDestroy(2);		// stream & fs
sl@0
   167
	}
sl@0
   168