1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/caf/streamableptrarray.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,100 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 + @publishedPartner
1.27 + @released
1.28 +*/
1.29 +
1.30 +
1.31 +#ifndef __STREAMABLEPTRARRAY_H__
1.32 +#define __STREAMABLEPTRARRAY_H__
1.33 +
1.34 +#include <e32base.h>
1.35 +#include <s32strm.h>
1.36 +
1.37 +namespace ContentAccess
1.38 + {
1.39 + /** Template class used to store an array of pointers that can also write itself to a stream
1.40 +
1.41 + The RStreamablePtrArray owns all the elements contained within it. The close
1.42 + function must be called before the RStreamablePtrArray goes out of scope.
1.43 +
1.44 + The close function frees all resources and deletes all array elements
1.45 +
1.46 + The array can be streamed using the InternalizeL() and ExternalizeL() functions
1.47 +
1.48 + @publishedPartner
1.49 + @released
1.50 + */
1.51 + template <class T>
1.52 + class RStreamablePtrArray
1.53 + {
1.54 + public:
1.55 + /** Constructor */
1.56 + inline RStreamablePtrArray();
1.57 +
1.58 + /** Free all resources held by the array
1.59 +
1.60 + Calls ResetAndDestroy();
1.61 + */
1.62 + inline void Close();
1.63 +
1.64 + /** Append an element to the array
1.65 +
1.66 + Ownership of the pointer is transferred to the array
1.67 + @param aElement The item to add to the array
1.68 + */
1.69 + inline void AppendL(T* aElement);
1.70 +
1.71 + /** Count the number of objects in the array */
1.72 + inline TInt Count() const;
1.73 +
1.74 + /** Return a pointer to an element at a given index in the array
1.75 +
1.76 + @param aIndex The zero based index in the array, must be less than Count()
1.77 + @return A pointer to the object stored in the array
1.78 + */
1.79 + inline T* operator [] (TInt aIndex) const;
1.80 +
1.81 + /** Delete all elements in the array*/
1.82 + inline void ResetAndDestroy();
1.83 +
1.84 + /** Add array elements from a stream */
1.85 + inline void InternalizeL(RReadStream& aStream);
1.86 +
1.87 + /** Write the entire array to a stream */
1.88 + inline void ExternalizeL(RWriteStream& aStream) const;
1.89 +
1.90 + /** Remove an element from the array.
1.91 + Note that the function does not delete the pointer.
1.92 + */
1.93 + inline void RemoveL(TInt aIndex);
1.94 +
1.95 + private:
1.96 + RPointerArray <T> iArray;
1.97 + };
1.98 + }
1.99 +
1.100 +// include inline function definitions
1.101 +#include <caf/streamableptrarray.inl>
1.102 +
1.103 +#endif