|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Contains CNcdNodeCacheCleanerManager class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_CACHE_CLEANER_MANAGER_H |
|
20 #define NCD_NODE_CACHE_CLEANER_MANAGER_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 // For array and uid |
|
26 #include <e32cmn.h> |
|
27 |
|
28 |
|
29 class CNcdNodeManager; |
|
30 class CNcdNodeDbManager; |
|
31 class CNcdNodeFactory; |
|
32 class CNcdNodeCacheCleaner; |
|
33 class CNcdGeneralManager; |
|
34 |
|
35 /** |
|
36 * This class object provides db cleaner maanger that can be used |
|
37 * to get db cache cleaners for certain clients that are identified |
|
38 * by the Uid. |
|
39 * |
|
40 * @lib ?library |
|
41 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
42 */ |
|
43 class CNcdNodeCacheCleanerManager : public CBase |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 /** |
|
49 * NewL |
|
50 * |
|
51 * @param aNodeManager |
|
52 * @param aNodeDbManager |
|
53 * @param aDbDefaultMaxSize The default value for the maximum size of |
|
54 * the database in bytes. If this size is exceeded, then the db should |
|
55 * be cleaned. |
|
56 * @param aNodeFactory |
|
57 * @return CNcdNodeCacheCleanerManager* Pointer to the created object |
|
58 * of this class. |
|
59 */ |
|
60 static CNcdNodeCacheCleanerManager* NewL( CNcdGeneralManager& aGeneralManager, |
|
61 CNcdNodeDbManager& aNodeDbManager, |
|
62 TInt aDbDefaultMaxSize, |
|
63 CNcdNodeFactory& aNodeFactory ); |
|
64 |
|
65 /** |
|
66 * @see CNcdNodeCacheCleaner::NewL |
|
67 */ |
|
68 static CNcdNodeCacheCleanerManager* NewLC( CNcdGeneralManager& aGeneralManager, |
|
69 CNcdNodeDbManager& aNodeDbManager, |
|
70 TInt aDbDefaultMaxSize, |
|
71 CNcdNodeFactory& aNodeFactory ); |
|
72 |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 virtual ~CNcdNodeCacheCleanerManager(); |
|
78 |
|
79 |
|
80 /** |
|
81 * Returns the cache cleaner or creates a new one if one did not exist |
|
82 * for the client of the given uid. |
|
83 * |
|
84 * @return CNcdNodeCacheCleaner& Reference to the cache cleaner that |
|
85 * corresponds the client of the given uid. |
|
86 */ |
|
87 CNcdNodeCacheCleaner& CacheCleanerL( const TUid& aClientUid ); |
|
88 |
|
89 |
|
90 /** |
|
91 * @return TInt The maximum size of the db in bytes. |
|
92 */ |
|
93 TInt DbMaxSize() const; |
|
94 |
|
95 /** |
|
96 * This function can be used to set the client specific max size |
|
97 * for the db. This value replaces the default value that was set in |
|
98 * the constructor of this class. |
|
99 * |
|
100 * @param aDbMaxSize The maximum size for the db in bytes. |
|
101 * If this size is exceeded, then the cleanup should be started and |
|
102 * db cleaned until the db max size is not exceeded any more. |
|
103 */ |
|
104 void SetDbMaxSize( const TInt aDbMaxSize ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Uses all the cache cleaners to check the db sizes. |
|
109 * In other words, calls CheckDbSizeL function of all the cache cleaners |
|
110 * created by this class object. |
|
111 */ |
|
112 void CheckAllL() const; |
|
113 |
|
114 |
|
115 protected: |
|
116 |
|
117 /** |
|
118 * Constructor |
|
119 */ |
|
120 CNcdNodeCacheCleanerManager( CNcdGeneralManager& aGeneralManager, |
|
121 CNcdNodeDbManager& aNodeDbManager, |
|
122 TInt aDbDefaultMaxSize, |
|
123 CNcdNodeFactory& aNodeFactory ); |
|
124 |
|
125 /** |
|
126 * ConstructL |
|
127 */ |
|
128 virtual void ConstructL(); |
|
129 |
|
130 |
|
131 /** |
|
132 * @return CNcdNodeManager& Manager that owns this cleaner |
|
133 */ |
|
134 CNcdNodeManager& NodeManager() const; |
|
135 |
|
136 /** |
|
137 * @return CNcdNodeDbManager& Database manager that provides functions |
|
138 * to handle database content. |
|
139 */ |
|
140 CNcdNodeDbManager& NodeDbManager() const; |
|
141 |
|
142 /** |
|
143 * @return CNcdNodeFactory& Factory that is used to create node |
|
144 * related class objects. |
|
145 */ |
|
146 CNcdNodeFactory& NodeFactory() const; |
|
147 |
|
148 |
|
149 private: |
|
150 |
|
151 // Prevent these two if they are not implemented |
|
152 CNcdNodeCacheCleanerManager( const CNcdNodeCacheCleanerManager& aObject ); |
|
153 CNcdNodeCacheCleanerManager& operator =( const CNcdNodeCacheCleanerManager& aObject ); |
|
154 |
|
155 private: // data |
|
156 |
|
157 CNcdGeneralManager& iGeneralManager; |
|
158 |
|
159 // Node manager that owns this class object. |
|
160 CNcdNodeManager& iNodeManager; |
|
161 |
|
162 // Data base manager is used to remove the nodes from the db. |
|
163 CNcdNodeDbManager& iNodeDbManager; |
|
164 |
|
165 // This contains the max db byte size |
|
166 TInt iDbMaxSize; |
|
167 |
|
168 // The factory is used to create the correct nodes. |
|
169 CNcdNodeFactory& iNodeFactory; |
|
170 |
|
171 // This array contains the cleaners. |
|
172 RPointerArray<CNcdNodeCacheCleaner> iCleaners; |
|
173 }; |
|
174 |
|
175 #endif // NCD_NODE_CACHE_CLEANER_MANAGER_H |