|
1 // Copyright (c) 1997-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 #ifndef __AGSENTRYMANAGER_H__ |
|
17 #define __AGSENTRYMANAGER_H__ |
|
18 |
|
19 #include <s32std.h> |
|
20 |
|
21 // ---------------------- Referenced classes ----------------------------------- |
|
22 class CAgnEntry; |
|
23 class TAgnEntryId; |
|
24 class TAgnEntryIter; |
|
25 |
|
26 class CAgnEntryManager : public CBase |
|
27 /** |
|
28 Manages adding,deleting and updating entries in the store. |
|
29 @internalAll |
|
30 @released |
|
31 */ |
|
32 { |
|
33 public: |
|
34 friend class TAgnEntryIter; |
|
35 enum TBufferType {ETodo,ERpt,EGeneral,EIterator}; |
|
36 |
|
37 static CAgnEntryManager* NewL(); |
|
38 ~CAgnEntryManager(); |
|
39 TStreamId AddEntryL(CAgnEntry& aEntry); |
|
40 TStreamId DeleteEntryL(const TAgnEntryId& aEntryId); |
|
41 CAgnEntry* FetchEntryL(const TAgnEntryId& aEntryId); |
|
42 TStreamId UpdateEntryL(CAgnEntry& aEntry,TStreamId& aNewStreamId); |
|
43 void StoreBuffersL(); |
|
44 void FlushBuffersL(); |
|
45 void FreeBuffers(); |
|
46 inline TBool BufferedDeleting() const; |
|
47 void SetBufferedDeleting(TBool aSetting); |
|
48 TAgnEntryId NextAvailableIdL(TBufferType aBufferType); |
|
49 inline void SetStore(CStreamStore& aStore); |
|
50 inline CStreamStore& StreamStore() const; |
|
51 inline TBool BufferHasBeenStored() const; |
|
52 void Reset(); |
|
53 TInt RestoreBufferL(const TStreamId& aStreamId); |
|
54 void InternalizeL(RReadStream& aStream); |
|
55 void ExternalizeL(RWriteStream& aStream) const; |
|
56 void CopyStreamIds(const CAgnEntryManager& aOriginalManager); |
|
57 private: |
|
58 class TBufItem |
|
59 /** |
|
60 @internalAll |
|
61 @released |
|
62 */ |
|
63 { |
|
64 public: |
|
65 inline TBufItem() {}; |
|
66 inline TBufItem(CAgnEntry* aEntry, TBool aToBeDeleted=EFalse); |
|
67 inline TBool ToBeDeleted() const; |
|
68 inline void SetToBeDeleted(TBool aSetting); |
|
69 inline void SetEntry(CAgnEntry* aEntry); |
|
70 inline CAgnEntry* Entry() const; |
|
71 private: |
|
72 CAgnEntry* iEntry; |
|
73 TBool iToBeDeleted; |
|
74 }; |
|
75 typedef CArrayFixFlat<TBufItem> CBuffer; |
|
76 |
|
77 CAgnEntryManager(); |
|
78 const CAgnEntry* operator[](TInt aIndex) const; |
|
79 void StoreBufferL(const TStreamId& aStreamId, const CBuffer* aBuffer, TBufferType aType); |
|
80 TUint FindUniqueIdPortion(const CBuffer* aBuffer); |
|
81 CAgnEntry* SearchBuffers(const TAgnEntryId& aEntryId, TInt& aPos); |
|
82 void SetBufferHasBeenStored(TBool aHasBeenStored, TBufferType aType); |
|
83 void FreeBuffer(TBufferType aBufferType); |
|
84 void DeleteEntriesInBufferFromStoreL(CBuffer* aBuffer, TInt& aNumEntriesToDelete); |
|
85 TStreamId DoAddEntryL(CAgnEntry& aEntry, TStreamId& aCurrentStreamId, TStreamId& aNextAvailableStreamId, CBuffer* aBuffer, TBufferType aBufferType); |
|
86 TStreamId DoDeleteEntryL(CAgnEntry* aEntry, CBuffer* aBuffer, TInt& aNumEntriesToDelete, TStreamId& aNextAvailableStreamId, |
|
87 const TStreamId& aCurrentStreamId, TBufferType aBufferType, TInt aPos); |
|
88 void StoreAndMaybeFreeBuffersL(TBool aFreeBuffers); |
|
89 |
|
90 CBuffer* iGeneralBuffer; |
|
91 CBuffer* iTodoBuffer; |
|
92 CBuffer* iRptBuffer; |
|
93 CBuffer* iIteratorBuffer; |
|
94 TStreamId iNextAvailableGeneralStreamId; |
|
95 TStreamId iNextAvailableTodoStreamId; |
|
96 TStreamId iNextAvailableRptStreamId; |
|
97 TStreamId iCurrentGeneralStreamId; |
|
98 TStreamId iCurrentTodoStreamId; |
|
99 TStreamId iCurrentRptStreamId; |
|
100 TInt iNumGeneralEntriesToDelete; |
|
101 TInt iNumTodoEntriesToDelete; |
|
102 TInt iNumRptEntriesToDelete; |
|
103 TBool iGeneralBufferHasBeenStored; |
|
104 TBool iTodoBufferHasBeenStored; |
|
105 TBool iRptBufferHasBeenStored; |
|
106 TBool iBufferHasBeenStored; |
|
107 CStreamStore* iStore; |
|
108 TBool iBufferedDeleting; |
|
109 TBufferType iLastRestored; |
|
110 mutable TBool iUseIteratorBuffer; |
|
111 }; |
|
112 |
|
113 #include "agsentrymanager.inl" |
|
114 |
|
115 #endif |