sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __STREAMABLEPTRARRAY_H__ sl@0: #define __STREAMABLEPTRARRAY_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: /** Template class used to store an array of pointers that can also write itself to a stream sl@0: sl@0: The RStreamablePtrArray owns all the elements contained within it. The close sl@0: function must be called before the RStreamablePtrArray goes out of scope. sl@0: sl@0: The close function frees all resources and deletes all array elements sl@0: sl@0: The array can be streamed using the InternalizeL() and ExternalizeL() functions sl@0: sl@0: */ sl@0: template sl@0: class RStreamablePtrArray sl@0: { sl@0: public: sl@0: /** Constructor */ sl@0: inline RStreamablePtrArray(); sl@0: sl@0: /** Free all resources held by the array sl@0: sl@0: Calls ResetAndDestroy(); sl@0: */ sl@0: inline void Close(); sl@0: sl@0: /** Append an element to the array sl@0: sl@0: Ownership of the pointer is transferred to the array sl@0: @param aElement The item to add to the array sl@0: */ sl@0: inline void AppendL(T* aElement); sl@0: sl@0: /** Count the number of objects in the array */ sl@0: inline TInt Count() const; sl@0: sl@0: /** Return a pointer to an element at a given index in the array sl@0: sl@0: @param aIndex The zero based index in the array, must be less than Count() sl@0: @return A pointer to the object stored in the array sl@0: */ sl@0: inline T* operator [] (TInt aIndex) const; sl@0: sl@0: /** Delete all elements in the array*/ sl@0: inline void ResetAndDestroy(); sl@0: sl@0: /** Add array elements from a stream */ sl@0: inline void InternalizeL(RReadStream& aStream); sl@0: sl@0: /** Write the entire array to a stream */ sl@0: inline void ExternalizeL(RWriteStream& aStream) const; sl@0: sl@0: /** Remove an element from the array. sl@0: Note that the function does not delete the pointer. sl@0: */ sl@0: inline void RemoveL(TInt aIndex); sl@0: sl@0: private: sl@0: RPointerArray iArray; sl@0: }; sl@0: } sl@0: sl@0: // include inline function definitions sl@0: #include sl@0: sl@0: #endif