os/security/contentmgmt/contentaccessfwfordrm/inc/StreamablePtrArray.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/inc/StreamablePtrArray.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     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 + @file
    1.24 + @publishedAll
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#ifndef __STREAMABLEPTRARRAY_H__
    1.30 +#define __STREAMABLEPTRARRAY_H__
    1.31 +
    1.32 +#include <e32base.h>
    1.33 +#include <s32strm.h>
    1.34 +
    1.35 +namespace ContentAccess
    1.36 +	{
    1.37 +	/** Template class used to store an array of pointers that can also write itself to a stream
    1.38 +
    1.39 +	The RStreamablePtrArray owns all the elements contained within it. The close 
    1.40 +	function must be called before the RStreamablePtrArray goes out of scope.
    1.41 +
    1.42 +	The close function frees all resources and deletes all array elements
    1.43 +	
    1.44 +	The array can be streamed using the InternalizeL() and ExternalizeL() functions
    1.45 +
    1.46 +  	*/
    1.47 +	template <class T>
    1.48 +		class RStreamablePtrArray
    1.49 +		{
    1.50 +	public:
    1.51 +		/** Constructor */
    1.52 +		inline RStreamablePtrArray();	
    1.53 +	
    1.54 +		/** Free all resources held by the array 
    1.55 +		
    1.56 +		Calls ResetAndDestroy();
    1.57 +		*/
    1.58 +		inline void Close();
    1.59 +
    1.60 +		/** Append an element to the array
    1.61 +		
    1.62 +		Ownership of the pointer is transferred to the array
    1.63 +		@param aElement The item to add to the array
    1.64 +		*/
    1.65 +		inline void AppendL(T* aElement);
    1.66 +
    1.67 +		/** Count the number of objects in the array */
    1.68 +		inline TInt Count() const;
    1.69 +
    1.70 +		/** Return a pointer to an element at a given index in the array
    1.71 +		
    1.72 +		@param aIndex The zero based index in the array, must be less than Count()
    1.73 +		@return A pointer to the object stored in the array
    1.74 +		*/
    1.75 +		inline T* operator [] (TInt aIndex) const;
    1.76 +		
    1.77 +		/** Delete all elements in the array*/
    1.78 +		inline void ResetAndDestroy();
    1.79 +		
    1.80 +		/** Add array elements from a stream */
    1.81 +		inline void InternalizeL(RReadStream& aStream);
    1.82 +
    1.83 +		/** Write the entire array to a stream */
    1.84 +		inline void ExternalizeL(RWriteStream& aStream) const;
    1.85 +
    1.86 +		/** Remove an element from the array.
    1.87 +		    Note that the function does not delete the pointer.
    1.88 +		 */
    1.89 +		inline void RemoveL(TInt aIndex);
    1.90 +
    1.91 +	private:
    1.92 +		RPointerArray <T> iArray;
    1.93 +		};
    1.94 +	}
    1.95 +
    1.96 +// include inline function definitions
    1.97 +#include <caf/streamableptrarray.inl>
    1.98 +
    1.99 +#endif