|
1 /* |
|
2 * Copyright (c) 2007 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: vector implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALF_PTRVECTOR_H |
|
20 #define ALF_PTRVECTOR_H |
|
21 |
|
22 |
|
23 #include <osn/osntypes.h> |
|
24 #include <osn/alfptrvectorimpl.h> |
|
25 |
|
26 namespace osncore |
|
27 { |
|
28 |
|
29 /** |
|
30 * @deprecated Use STL vector |
|
31 * @class AlfPtrVector alfptrvector.h "osn/alfptrvector.h" |
|
32 * Template class for a pointer vector |
|
33 * |
|
34 * @lib osncore.lib |
|
35 * @since S60 5.0 |
|
36 * @status Draft |
|
37 * @interfaces AlfPtrVector |
|
38 */ |
|
39 template<class T> |
|
40 class AlfPtrVector: public IDeleter |
|
41 { |
|
42 public: |
|
43 /** |
|
44 * @deprecated Use STL vector |
|
45 * Default constructor for vector. |
|
46 * By default contents are automatically deleted |
|
47 * when destructor is called. |
|
48 * |
|
49 * @since S60 5.0 |
|
50 */ |
|
51 AlfPtrVector() : mImpl(*this),mDelItem(true) {} |
|
52 |
|
53 /** |
|
54 * @deprecated Use STL vector |
|
55 * Constructor for vector with some default size. |
|
56 * Size can be increased or decreased afterwards. |
|
57 * |
|
58 * @since S60 5.0 |
|
59 * @param aSize Default size of vector. |
|
60 */ |
|
61 explicit AlfPtrVector(uint aSize) : mImpl(aSize,*this),mDelItem(true) {} |
|
62 |
|
63 /** |
|
64 * @deprecated Use STL vector |
|
65 * Destructor. |
|
66 */ |
|
67 ~AlfPtrVector() { if (mDelItem) { mImpl.clear(mDelItem); } } |
|
68 |
|
69 /** |
|
70 * @deprecated Use STL vector |
|
71 * Returns the value of auto delete property. |
|
72 * |
|
73 * @since S60 5.0 |
|
74 * @return true or false. |
|
75 */ |
|
76 bool autoDelete() { return mDelItem; } |
|
77 |
|
78 /** |
|
79 * @deprecated Use STL vector |
|
80 * Sets the auto delete property of vector. |
|
81 * |
|
82 * @since S60 5.0 |
|
83 * @param aAutoDelete Value(true/false) of the property.Default value is true. |
|
84 */ |
|
85 void setAutoDelete(bool aAutoDelete=true) { mDelItem = aAutoDelete; } |
|
86 |
|
87 /** |
|
88 * Deletes all items of vector. |
|
89 * |
|
90 * @since S60 5.0 |
|
91 */ |
|
92 void clear() { mImpl.clear(mDelItem); } |
|
93 |
|
94 /** |
|
95 * @deprecated Use STL vector |
|
96 * Checks if there are some items in vector. |
|
97 * |
|
98 * @since S60 5.0 |
|
99 * @return true or false. |
|
100 */ |
|
101 bool isEmpty() const { return mImpl.isEmpty(); } |
|
102 |
|
103 /** |
|
104 * @deprecated Use STL vector |
|
105 * Returns number of items in vector. |
|
106 * |
|
107 * @since S60 5.0 |
|
108 * @return number of items in vector. |
|
109 */ |
|
110 uint count() const { return mImpl.count(); } |
|
111 |
|
112 /** |
|
113 * @deprecated Use STL vector |
|
114 * Returns the size in bytes occupied by vector. |
|
115 * |
|
116 * @since S60 5.0 |
|
117 * @return number of bytes used by vector. |
|
118 */ |
|
119 uint size() const { return mImpl.size(); } |
|
120 |
|
121 /** |
|
122 * @deprecated Use STL vector |
|
123 * Removes the item from vector at given position. |
|
124 * Item will be automatically deleted if auto delete |
|
125 * property is set to true. |
|
126 * |
|
127 * @since S60 5.0 |
|
128 * @param aPos Position of the item to be removed. |
|
129 * @return true/false to indicate if item has been removed. |
|
130 */ |
|
131 bool remove(uint aPos) { return mImpl.remove(aPos, mDelItem); } |
|
132 |
|
133 /** |
|
134 * @deprecated Use STL vector |
|
135 * Resizes the vector to new size. Existing items in |
|
136 * the vector will be restored if auto delete property is false. |
|
137 * |
|
138 * @since S60 5.0 |
|
139 * @param aSize New size in bytes. |
|
140 * @return true/false to indicate if item has been resized. |
|
141 */ |
|
142 bool resize(uint aSize) { return mImpl.resize(aSize, mDelItem); } |
|
143 |
|
144 /** |
|
145 * @deprecated Use STL vector |
|
146 * Inserts a new item at given position in the vector. |
|
147 * |
|
148 * @since S60 5.0 |
|
149 * @param aPos Position at which item has to be inserted. |
|
150 * @param aItem Pointer to the item to be inserted. |
|
151 * @return true/false to indicate if the item has been inserted. |
|
152 */ |
|
153 bool insert(uint aPos, T *aItem) { return mImpl.insert(aPos, aItem, mDelItem); } |
|
154 |
|
155 /** |
|
156 * @deprecated Use STL vector |
|
157 * Returns pointer to the item at given position in the vector. |
|
158 * |
|
159 * @since S60 5.0 |
|
160 * @param aPos Position from which item is queried. |
|
161 * @return Pointer to the item. |
|
162 */ |
|
163 T *at(int aPos) const {return (T *)mImpl.at(aPos); } |
|
164 |
|
165 /** |
|
166 * @deprecated Use STL vector |
|
167 * Returns pointer to the raw data used by vector to stroe the items. |
|
168 * |
|
169 * @since S60 5.0 |
|
170 * @return Pointer to data. |
|
171 */ |
|
172 T **data() {return (T **)mImpl.data(); } |
|
173 |
|
174 /** |
|
175 * @deprecated Use STL vector |
|
176 * Returns the position of the item in the vector. |
|
177 * |
|
178 * @since S60 5.0 |
|
179 * @param aItem Pointer to the item being searched in the vector. |
|
180 * @return Position of item in the vector.-1 is returned if item is not found. |
|
181 */ |
|
182 int findRef(T *aItem){return mImpl.findRef(aItem);} |
|
183 |
|
184 /** |
|
185 * @deprecated Use STL vector |
|
186 * Returns the item at given index in the vector. |
|
187 * |
|
188 * @since S60 5.0 |
|
189 * @param aPos Position from which item has been queried. |
|
190 * @return Pointer to the item at given position. |
|
191 */ |
|
192 T* operator[](uint aPos) const { return (T *)mImpl.at(aPos); } |
|
193 |
|
194 private: |
|
195 void deleteItem(void* aItem) |
|
196 { |
|
197 delete (T*) aItem; |
|
198 } |
|
199 AlfPtrVector(const AlfPtrVector&); |
|
200 AlfPtrVector& operator=(const AlfPtrVector&); |
|
201 private: |
|
202 /** |
|
203 * Owned body |
|
204 */ |
|
205 AlfPtrVectorImpl mImpl; |
|
206 /** |
|
207 * Auto delete |
|
208 */ |
|
209 bool mDelItem; |
|
210 |
|
211 }; |
|
212 |
|
213 } |
|
214 #endif |