os/security/contentmgmt/contentaccessfwfordrm/inc/StreamablePtrArray.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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  @file
    21  @publishedAll
    22  @released
    23 */
    24 
    25 
    26 #ifndef __STREAMABLEPTRARRAY_H__
    27 #define __STREAMABLEPTRARRAY_H__
    28 
    29 #include <e32base.h>
    30 #include <s32strm.h>
    31 
    32 namespace ContentAccess
    33 	{
    34 	/** Template class used to store an array of pointers that can also write itself to a stream
    35 
    36 	The RStreamablePtrArray owns all the elements contained within it. The close 
    37 	function must be called before the RStreamablePtrArray goes out of scope.
    38 
    39 	The close function frees all resources and deletes all array elements
    40 	
    41 	The array can be streamed using the InternalizeL() and ExternalizeL() functions
    42 
    43   	*/
    44 	template <class T>
    45 		class RStreamablePtrArray
    46 		{
    47 	public:
    48 		/** Constructor */
    49 		inline RStreamablePtrArray();	
    50 	
    51 		/** Free all resources held by the array 
    52 		
    53 		Calls ResetAndDestroy();
    54 		*/
    55 		inline void Close();
    56 
    57 		/** Append an element to the array
    58 		
    59 		Ownership of the pointer is transferred to the array
    60 		@param aElement The item to add to the array
    61 		*/
    62 		inline void AppendL(T* aElement);
    63 
    64 		/** Count the number of objects in the array */
    65 		inline TInt Count() const;
    66 
    67 		/** Return a pointer to an element at a given index in the array
    68 		
    69 		@param aIndex The zero based index in the array, must be less than Count()
    70 		@return A pointer to the object stored in the array
    71 		*/
    72 		inline T* operator [] (TInt aIndex) const;
    73 		
    74 		/** Delete all elements in the array*/
    75 		inline void ResetAndDestroy();
    76 		
    77 		/** Add array elements from a stream */
    78 		inline void InternalizeL(RReadStream& aStream);
    79 
    80 		/** Write the entire array to a stream */
    81 		inline void ExternalizeL(RWriteStream& aStream) const;
    82 
    83 		/** Remove an element from the array.
    84 		    Note that the function does not delete the pointer.
    85 		 */
    86 		inline void RemoveL(TInt aIndex);
    87 
    88 	private:
    89 		RPointerArray <T> iArray;
    90 		};
    91 	}
    92 
    93 // include inline function definitions
    94 #include <caf/streamableptrarray.inl>
    95 
    96 #endif