|
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 __AGSITERATOR_H__ |
|
17 #define __AGSITERATOR_H__ |
|
18 |
|
19 #include "agmfilter.h" |
|
20 #include "agmids.h" |
|
21 |
|
22 // ----------------------------------- Reference classes ----------------------- |
|
23 class CAgnEntryManager; |
|
24 class CAgnIndex; |
|
25 class CAgnSimpleEntry; |
|
26 class CAgnStreamIdSet; |
|
27 |
|
28 // ----------------------------------- TAgnIteratorBase------------------------- |
|
29 class TAgnIteratorBase |
|
30 /** |
|
31 Base class for instance iterators. |
|
32 @internalAll |
|
33 @released |
|
34 */ |
|
35 { |
|
36 public: |
|
37 TAgnIteratorBase() {}; |
|
38 virtual void StartL() = 0; |
|
39 virtual void NextL() = 0; |
|
40 virtual void PreviousL() = 0; |
|
41 virtual TBool AtEnd() = 0; |
|
42 virtual TBool AtStart() = 0; |
|
43 virtual TBool GotoL(TTime& aKeyValue) = 0; |
|
44 virtual TBool GotoLessOrEqualL(TTime& aKeyValue) = 0; |
|
45 virtual const TTime& CurrentKey() const = 0; |
|
46 virtual const CAgnSimpleEntry& CurrentElement() const = 0; |
|
47 }; |
|
48 |
|
49 class TAgnIterator : public TAgnIteratorBase |
|
50 /** |
|
51 @internalAll |
|
52 @released |
|
53 */ |
|
54 { |
|
55 public: |
|
56 |
|
57 TAgnIterator(); |
|
58 TAgnIterator(CAgnIndex* aIndex, const TAgnFilter& aFilter); |
|
59 void StartL(); |
|
60 virtual void NextL(); |
|
61 virtual void PreviousL(); |
|
62 virtual TBool GotoL(TTime& aKeyValue); |
|
63 virtual TBool GotoLessOrEqualL(TTime& aKeyValue); |
|
64 const CAgnSimpleEntry& CurrentElement() const; |
|
65 virtual const TTime& CurrentKey() const; |
|
66 virtual TBool AtEnd(); |
|
67 virtual TBool AtStart(); |
|
68 |
|
69 inline void SetIndex(CAgnIndex& aSimpleEntryIndex); |
|
70 inline void SetFilter(const TAgnFilter& aFilter); |
|
71 inline const TAgnFilter* Filter(); |
|
72 inline const void SetUndatedTodoTime(const TTime& aUndatedTodoTime); |
|
73 |
|
74 protected: |
|
75 TBool IsValidElement(); // Current element valid w.r.t. filter |
|
76 void SetCursor(TInt aCursor); |
|
77 TInt Cursor() const; |
|
78 const CAgnIndex* Array() const; |
|
79 void SetCurrentKey(const TTime& aKeyValue); |
|
80 TBool FirstL(TTime& aTargetKey); |
|
81 TBool FirstLessOrEqualL(TTime& aTargetKey); |
|
82 virtual TBool MovedForwardL(TTime /*aTargetValue*/) {return ETrue;} |
|
83 virtual TBool MovedToL(TTime /*aTargetValue*/) {return ETrue;} |
|
84 virtual TBool MovedBackL(TTime /*aTargetValue*/) {return ETrue;} |
|
85 TTime iCurrentKey; |
|
86 TTime iPreviousKey; |
|
87 TTime iUndatedTodoTime; |
|
88 private: |
|
89 TInt iCursor; |
|
90 TAgnFilter iFilter; |
|
91 CAgnIndex* iArray; |
|
92 }; |
|
93 |
|
94 class TAgnEntryIter |
|
95 /** Iterates over the entries in an agenda file. |
|
96 |
|
97 @internalAll |
|
98 @released |
|
99 */ |
|
100 { |
|
101 public: |
|
102 TAgnEntryIter(CAgnStreamIdSet& aStreamIdSet, CAgnEntryManager& aEntryManager); |
|
103 TBool SetToFirstL(); // position to the first entry |
|
104 TBool NextL(); // position to the next entry |
|
105 TAgnEntryId At(); // return the entry id of the current entry |
|
106 |
|
107 private: |
|
108 CAgnStreamIdSet& iStreamIdSet; |
|
109 CAgnEntryManager& iEntryManager; |
|
110 TInt iEntryIter; |
|
111 TInt iEntryCount; |
|
112 }; |
|
113 |
|
114 #include "agsiterator.inl" |
|
115 |
|
116 #endif |