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