Update contrib.
1 // Copyright (c) 2008-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 the License "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 // e32\debug\crashMonitor\src\scmlockdata.cpp
15 // some utility classes for writing data to flash buffer
25 #include <scmdatatypes.h>
31 * TSCMLockData constructor
34 TSCMLockData::TSCMLockData()
37 , iMutexThreadWaitCount(-1)
42 * TSCMLockData Serialize
43 * @param aWriter byte stream to use
46 TInt TSCMLockData::Serialize(TByteStreamWriter& aWriter)
48 TInt startPos = aWriter.CurrentPosition();
53 CLTRACE("TSCMLockData::Serialize Corrupt ID");
58 aWriter.WriteInt(iId); // 4
59 // 2 counts written as shorts (should be enough range!)
60 aWriter.WriteShort((TInt16) iMutexHoldCount); // 2
61 aWriter.WriteShort((TInt16) iMutexThreadWaitCount); // 2
62 aWriter.WriteShort((TInt16) iLockCount); // 2
65 TInt endPos = aWriter.CurrentPosition();
66 if( endPos - startPos != GetSize())
68 // error between actual size & real size in data
69 CLTRACE("TSCMLockData::Serialize serialization size error");
77 * Reads the classes data from the specified byte stream
78 * @param aReader Byte stream to use
81 TInt TSCMLockData::Deserialize(TByteStreamReader& aReader)
83 TInt startPos = aReader.CurrentPosition();
85 iId = (SCMStructId)aReader.ReadInt(); // 4
88 CLTRACE("TSCMLockData::Deserialize Corrupt ID read");
92 iMutexHoldCount = (TInt) aReader.ReadShort();
93 iMutexThreadWaitCount = (TInt) aReader.ReadShort();
94 iLockCount = (TInt) aReader.ReadShort();
97 TInt endPos = aReader.CurrentPosition();
98 if( endPos - startPos != GetSize())
100 CLTRACE("TSCMLockData::Deserialize size error");
107 * Returns the externalised size of this class
110 TInt TSCMLockData::GetSize() const
112 return KSCMLockDataMaxSize;
118 * @return mutex hold count
120 TInt TSCMLockData::MutexHoldCount() const
122 return iMutexHoldCount;
130 void TSCMLockData::SetMutexHoldCount(TInt aMutexHoldCount)
132 iMutexHoldCount = aMutexHoldCount;
136 * MutexThreadWaitCount
138 * @return number of threads waiting on held mutex - will only be valid if
141 TInt TSCMLockData::MutexThreadWaitCount() const
143 return iMutexThreadWaitCount;
147 * SetMutexThreadWaitCount
148 * @param TInt - number of threads waiting on held mutex(es)
151 void TSCMLockData::SetMutexThreadWaitCount(TInt aMutexThreadWaitCount)
153 iMutexThreadWaitCount = aMutexThreadWaitCount;
159 * @return TIOnt - the lock count
161 TInt TSCMLockData::LockCount() const
168 * @param TInt - number of locks held
171 void TSCMLockData::SetLockCount(TInt aLockCount)
173 iLockCount = aLockCount;
176 TBool TSCMLockData::operator == (const TSCMLockData& aOther) const
178 return ( iId == aOther.iId &&
179 iMutexHoldCount == aOther.iMutexHoldCount &&
180 iMutexThreadWaitCount == aOther.iMutexThreadWaitCount &&
181 iLockCount == aOther.iLockCount );
184 TBool TSCMLockData::operator != (const TSCMLockData& aOther) const
186 return !(*this == aOther);