sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@publishedAll
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __STREAMABLEPTRARRAY_H__
|
sl@0
|
27 |
#define __STREAMABLEPTRARRAY_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <e32base.h>
|
sl@0
|
30 |
#include <s32strm.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
namespace ContentAccess
|
sl@0
|
33 |
{
|
sl@0
|
34 |
/** Template class used to store an array of pointers that can also write itself to a stream
|
sl@0
|
35 |
|
sl@0
|
36 |
The RStreamablePtrArray owns all the elements contained within it. The close
|
sl@0
|
37 |
function must be called before the RStreamablePtrArray goes out of scope.
|
sl@0
|
38 |
|
sl@0
|
39 |
The close function frees all resources and deletes all array elements
|
sl@0
|
40 |
|
sl@0
|
41 |
The array can be streamed using the InternalizeL() and ExternalizeL() functions
|
sl@0
|
42 |
|
sl@0
|
43 |
*/
|
sl@0
|
44 |
template <class T>
|
sl@0
|
45 |
class RStreamablePtrArray
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
/** Constructor */
|
sl@0
|
49 |
inline RStreamablePtrArray();
|
sl@0
|
50 |
|
sl@0
|
51 |
/** Free all resources held by the array
|
sl@0
|
52 |
|
sl@0
|
53 |
Calls ResetAndDestroy();
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
inline void Close();
|
sl@0
|
56 |
|
sl@0
|
57 |
/** Append an element to the array
|
sl@0
|
58 |
|
sl@0
|
59 |
Ownership of the pointer is transferred to the array
|
sl@0
|
60 |
@param aElement The item to add to the array
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
inline void AppendL(T* aElement);
|
sl@0
|
63 |
|
sl@0
|
64 |
/** Count the number of objects in the array */
|
sl@0
|
65 |
inline TInt Count() const;
|
sl@0
|
66 |
|
sl@0
|
67 |
/** Return a pointer to an element at a given index in the array
|
sl@0
|
68 |
|
sl@0
|
69 |
@param aIndex The zero based index in the array, must be less than Count()
|
sl@0
|
70 |
@return A pointer to the object stored in the array
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
inline T* operator [] (TInt aIndex) const;
|
sl@0
|
73 |
|
sl@0
|
74 |
/** Delete all elements in the array*/
|
sl@0
|
75 |
inline void ResetAndDestroy();
|
sl@0
|
76 |
|
sl@0
|
77 |
/** Add array elements from a stream */
|
sl@0
|
78 |
inline void InternalizeL(RReadStream& aStream);
|
sl@0
|
79 |
|
sl@0
|
80 |
/** Write the entire array to a stream */
|
sl@0
|
81 |
inline void ExternalizeL(RWriteStream& aStream) const;
|
sl@0
|
82 |
|
sl@0
|
83 |
/** Remove an element from the array.
|
sl@0
|
84 |
Note that the function does not delete the pointer.
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
inline void RemoveL(TInt aIndex);
|
sl@0
|
87 |
|
sl@0
|
88 |
private:
|
sl@0
|
89 |
RPointerArray <T> iArray;
|
sl@0
|
90 |
};
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
// include inline function definitions
|
sl@0
|
94 |
#include <caf/streamableptrarray.inl>
|
sl@0
|
95 |
|
sl@0
|
96 |
#endif
|