os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionStateAccessor.inl
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The implementation of the accessor class upon the CTransition
18 // ______________________________________________________________________________
20 _LIT(KTTransition_DumpName,"C:\\System\\Data\\Logs\\TTransition_StateDump.bin");
22 inline TInt TTransition_StateAccessor::InvariantTest(TAny* aTestObject)
26 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
27 if(theTransition->iTransitionId.Length() == 0)
33 inline TInt TTransition_StateAccessor::Internalize(TAny* aTestObject)
35 TInt error = KErrNone;
36 if(aTestObject != NULL)
38 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
39 TRAP(error,InternalizeL(theTransition));
44 inline TInt TTransition_StateAccessor::Externalize(TAny* aTestObject)
46 TInt error = KErrNone;
47 if(aTestObject != NULL)
49 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
50 TRAP(error,ExternalizeL(theTransition));
55 inline TBool TTransition_StateAccessor::IsRepeated(TAny* aTestObject) const
57 if(aTestObject != NULL)
59 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
60 return theTransition->iRepeatThis;
65 inline const TDesC* TTransition_StateAccessor::TransitionId(TAny* aTestObject) const
67 if(aTestObject != NULL)
69 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
70 return &(theTransition->iTransitionId);
75 inline const TTransitionInfo* TTransition_StateAccessor::TransitionInfo(TAny* aTestObject) const
77 if(aTestObject != NULL)
79 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
80 return &(theTransition->iTransitionInfo);
85 inline TBool TTransition_StateAccessor::BlockingFlag(TAny* aTestObject) const
87 if(aTestObject != NULL)
89 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
90 return theTransition->iBlockingTransition;
95 inline TInt TTransition_StateAccessor::ErrorCode(TAny* aTestObject) const
97 if(aTestObject != NULL)
99 CTransition* theTransition = REINTERPRET_CAST(CTransition*, aTestObject);
100 return theTransition->iLeaveError;
105 inline TRequestStatus TTransition_StateAccessor::Status(const TAny* aTestObject) const
107 TRequestStatus status;
108 Mem::FillZ(&status, sizeof(status));
109 if(aTestObject != NULL)
111 status = (reinterpret_cast <const CTransition*> (aTestObject))->iStatus;
116 inline void TTransition_StateAccessor::InternalizeL(RFileReadStream& aStream, CTransition* aTransition)
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);
126 inline void TTransition_StateAccessor::ExternalizeL(RFileWriteStream& aStream, CTransition* aTransition)
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);
137 inline void TTransition_StateAccessor::InternalizeL(CTransition* aTransition)
139 // Read in the dumped data
141 User::LeaveIfError(fs.Connect());
142 CleanupClosePushL(fs);
143 // Read the object dump
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
153 inline void TTransition_StateAccessor::ExternalizeL(CTransition* aTransition)
156 User::LeaveIfError(fs.Connect());
157 CleanupClosePushL(fs);
158 // Write out the object dump
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);
166 CleanupStack::PopAndDestroy(2); // stream & fs