contentmgmt/contentaccessfwfordrm/inc/StreamablePtrArray.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 
       
    28 #ifndef __STREAMABLEPTRARRAY_H__
       
    29 #define __STREAMABLEPTRARRAY_H__
       
    30 
       
    31 #include <e32base.h>
       
    32 #include <s32strm.h>
       
    33 
       
    34 namespace ContentAccess
       
    35 	{
       
    36 	/** Template class used to store an array of pointers that can also write itself to a stream
       
    37 
       
    38 	The RStreamablePtrArray owns all the elements contained within it. The close 
       
    39 	function must be called before the RStreamablePtrArray goes out of scope.
       
    40 
       
    41 	The close function frees all resources and deletes all array elements
       
    42 	
       
    43 	The array can be streamed using the InternalizeL() and ExternalizeL() functions
       
    44 
       
    45   	@publishedPartner
       
    46 	@released
       
    47 	*/
       
    48 	template <class T>
       
    49 		class RStreamablePtrArray
       
    50 		{
       
    51 	public:
       
    52 		/** Constructor */
       
    53 		inline RStreamablePtrArray();	
       
    54 	
       
    55 		/** Free all resources held by the array 
       
    56 		
       
    57 		Calls ResetAndDestroy();
       
    58 		*/
       
    59 		inline void Close();
       
    60 
       
    61 		/** Append an element to the array
       
    62 		
       
    63 		Ownership of the pointer is transferred to the array
       
    64 		@param aElement The item to add to the array
       
    65 		*/
       
    66 		inline void AppendL(T* aElement);
       
    67 
       
    68 		/** Count the number of objects in the array */
       
    69 		inline TInt Count() const;
       
    70 
       
    71 		/** Return a pointer to an element at a given index in the array
       
    72 		
       
    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
       
    75 		*/
       
    76 		inline T* operator [] (TInt aIndex) const;
       
    77 		
       
    78 		/** Delete all elements in the array*/
       
    79 		inline void ResetAndDestroy();
       
    80 		
       
    81 		/** Add array elements from a stream */
       
    82 		inline void InternalizeL(RReadStream& aStream);
       
    83 
       
    84 		/** Write the entire array to a stream */
       
    85 		inline void ExternalizeL(RWriteStream& aStream) const;
       
    86 
       
    87 		/** Remove an element from the array.
       
    88 		    Note that the function does not delete the pointer.
       
    89 		 */
       
    90 		inline void RemoveL(TInt aIndex);
       
    91 
       
    92 	private:
       
    93 		RPointerArray <T> iArray;
       
    94 		};
       
    95 	}
       
    96 
       
    97 // include inline function definitions
       
    98 #include <caf/streamableptrarray.inl>
       
    99 
       
   100 #endif