|
1 // Copyright (c) 1998-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 // |
|
15 |
|
16 #include "UT_STD.H" |
|
17 |
|
18 GLDEF_C void Panic(TStorePanic aPanic) |
|
19 // |
|
20 // Panic the process with STORE-Store as the category. |
|
21 // |
|
22 { |
|
23 _LIT(KCategory,"STORE-Store"); |
|
24 User::Panic(KCategory,aPanic); |
|
25 } |
|
26 |
|
27 EXPORT_C void TStreamId::InternalizeL(RReadStream& aStream) |
|
28 /** Internalises an object of this class from a read stream. |
|
29 |
|
30 The presence of this function means that the standard templated operator>>() |
|
31 can be used to internalise objects of this class. |
|
32 |
|
33 Note that the function has assignment semantics. It replaces the old value |
|
34 of the object with a new value read from the read stream. |
|
35 |
|
36 @param aStream Stream from which the object should be internalised. */ |
|
37 { |
|
38 aStream>>iVal; |
|
39 if (iVal>KMaxStreamIdValue) |
|
40 __LEAVE(KErrCorrupt); |
|
41 } |
|
42 |
|
43 EXPORT_C void MIncrementalCollector::DoRelease() |
|
44 /** Implementation of the public Release() function. This signals that client has |
|
45 no further need of the object and all necessary clean-up should be done. e.g. |
|
46 if the implementation object is allocated on the heap, it could be deleted. */ |
|
47 {} |
|
48 |
|
49 EXPORT_C void MIncrementalCollector::DoNextL(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus,TPckgBuf<TInt>& aTotal) |
|
50 /** Implementation of the public asynchronous NextL() function. The default implementation |
|
51 invokes the synchronous form of DoNextL() and then reports the result by signalling |
|
52 the request status. |
|
53 |
|
54 @param aStep The progress value from either the last NextL() increment of |
|
55 from ResetL() if the reclamation/compaction was restarted. On return, |
|
56 should contain the new progress value, which can be used in subsequent calls |
|
57 to NextL(). This must be equal to, or less than, the previous value a |
|
58 zero value must be used to indicate that the operation is complete. |
|
59 @param aStatus A status variable. KErrNone on successful completion, otherwise |
|
60 another of the system-wide error codes. |
|
61 @param aTotal On return, should contain the total amount of free space in the |
|
62 store. */ |
|
63 { |
|
64 DoNextL(aStep(),aTotal()); |
|
65 TRequestStatus* stat=&aStatus; |
|
66 User::RequestComplete(stat,KErrNone); |
|
67 } |
|
68 |
|
69 HDirectStoreBuf* HDirectStoreBuf::CreateL(TStreamExchange& aHost,TStreamId& anId,TInt aMode) |
|
70 // |
|
71 // Create a stream buffer for a new 'direct' stream. |
|
72 // |
|
73 { |
|
74 TInt size=aHost.SizeL(); |
|
75 HDirectStoreBuf* buf=NewL(aHost,size,aMode); |
|
76 anId=TStreamId(size); |
|
77 return buf; |
|
78 } |
|
79 |
|
80 HDirectStoreBuf* HDirectStoreBuf::OpenL(TStreamExchange& aHost,TStreamId anId,TInt aMode) |
|
81 // |
|
82 // Create a stream buffer for an existing 'direct' stream. |
|
83 // |
|
84 { |
|
85 HDirectStoreBuf* buf=NewL(aHost,anId.Value(),aMode); |
|
86 return buf; |
|
87 } |
|
88 |
|
89 HDirectStoreBuf* HDirectStoreBuf::NewL(TStreamExchange& aHost,TInt anOffset,TInt aMode) |
|
90 { |
|
91 HDirectStoreBuf* buf=new(ELeave) HDirectStoreBuf(anOffset); |
|
92 buf->Open(aHost,TStreamPos(anOffset),aMode); |
|
93 return buf; |
|
94 } |
|
95 |
|
96 void HDirectStoreBuf::DoRelease() |
|
97 // |
|
98 // Finished with this stream buffer. |
|
99 // |
|
100 { |
|
101 delete this; |
|
102 } |
|
103 |
|
104 TStreamPos HDirectStoreBuf::DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset) |
|
105 // |
|
106 // Position the mark(s) indicated by aMark at anOffset from aLocation. |
|
107 // |
|
108 { |
|
109 TInt off=iOff; |
|
110 if (aLocation==EStreamBeginning) |
|
111 anOffset+=off; |
|
112 return RShareBuf::DoSeekL(aMark,aLocation,anOffset)-off; |
|
113 } |
|
114 |
|
115 EXPORT_C void TStreamId::__DbgChkRange(TUint32 aValue) |
|
116 // |
|
117 // Check for values out of range. |
|
118 // |
|
119 { |
|
120 __ASSERT_ALWAYS(aValue<=KMaxStreamIdValue,Panic(EStoreIdOutOfRange)); |
|
121 } |
|
122 |