2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #ifndef __STREAMABLEPTRARRAY_H__
29 #define __STREAMABLEPTRARRAY_H__
34 namespace ContentAccess
36 /** Template class used to store an array of pointers that can also write itself to a stream
38 The RStreamablePtrArray owns all the elements contained within it. The close
39 function must be called before the RStreamablePtrArray goes out of scope.
41 The close function frees all resources and deletes all array elements
43 The array can be streamed using the InternalizeL() and ExternalizeL() functions
49 class RStreamablePtrArray
53 inline RStreamablePtrArray();
55 /** Free all resources held by the array
57 Calls ResetAndDestroy();
61 /** Append an element to the array
63 Ownership of the pointer is transferred to the array
64 @param aElement The item to add to the array
66 inline void AppendL(T* aElement);
68 /** Count the number of objects in the array */
69 inline TInt Count() const;
71 /** Return a pointer to an element at a given index in the array
73 @param aIndex The zero based index in the array, must be less than Count()
74 @return A pointer to the object stored in the array
76 inline T* operator [] (TInt aIndex) const;
78 /** Delete all elements in the array*/
79 inline void ResetAndDestroy();
81 /** Add array elements from a stream */
82 inline void InternalizeL(RReadStream& aStream);
84 /** Write the entire array to a stream */
85 inline void ExternalizeL(RWriteStream& aStream) const;
87 /** Remove an element from the array.
88 Note that the function does not delete the pointer.
90 inline void RemoveL(TInt aIndex);
93 RPointerArray <T> iArray;
97 // include inline function definitions
98 #include <caf/streamableptrarray.inl>