epoc32/include/caf/streamableptrarray.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
/**
williamr@2
    20
 @file
williamr@4
    21
 @publishedAll
williamr@2
    22
 @released
williamr@2
    23
*/
williamr@2
    24
williamr@2
    25
williamr@2
    26
#ifndef __STREAMABLEPTRARRAY_H__
williamr@2
    27
#define __STREAMABLEPTRARRAY_H__
williamr@2
    28
williamr@2
    29
#include <e32base.h>
williamr@2
    30
#include <s32strm.h>
williamr@2
    31
williamr@2
    32
namespace ContentAccess
williamr@2
    33
	{
williamr@2
    34
	/** Template class used to store an array of pointers that can also write itself to a stream
williamr@2
    35
williamr@2
    36
	The RStreamablePtrArray owns all the elements contained within it. The close 
williamr@2
    37
	function must be called before the RStreamablePtrArray goes out of scope.
williamr@2
    38
williamr@2
    39
	The close function frees all resources and deletes all array elements
williamr@2
    40
	
williamr@2
    41
	The array can be streamed using the InternalizeL() and ExternalizeL() functions
williamr@2
    42
williamr@4
    43
  	*/
williamr@2
    44
	template <class T>
williamr@2
    45
		class RStreamablePtrArray
williamr@2
    46
		{
williamr@2
    47
	public:
williamr@2
    48
		/** Constructor */
williamr@2
    49
		inline RStreamablePtrArray();	
williamr@2
    50
	
williamr@2
    51
		/** Free all resources held by the array 
williamr@2
    52
		
williamr@2
    53
		Calls ResetAndDestroy();
williamr@2
    54
		*/
williamr@2
    55
		inline void Close();
williamr@2
    56
williamr@2
    57
		/** Append an element to the array
williamr@2
    58
		
williamr@2
    59
		Ownership of the pointer is transferred to the array
williamr@2
    60
		@param aElement The item to add to the array
williamr@2
    61
		*/
williamr@2
    62
		inline void AppendL(T* aElement);
williamr@2
    63
williamr@2
    64
		/** Count the number of objects in the array */
williamr@2
    65
		inline TInt Count() const;
williamr@2
    66
williamr@2
    67
		/** Return a pointer to an element at a given index in the array
williamr@2
    68
		
williamr@2
    69
		@param aIndex The zero based index in the array, must be less than Count()
williamr@2
    70
		@return A pointer to the object stored in the array
williamr@2
    71
		*/
williamr@2
    72
		inline T* operator [] (TInt aIndex) const;
williamr@2
    73
		
williamr@2
    74
		/** Delete all elements in the array*/
williamr@2
    75
		inline void ResetAndDestroy();
williamr@2
    76
		
williamr@2
    77
		/** Add array elements from a stream */
williamr@2
    78
		inline void InternalizeL(RReadStream& aStream);
williamr@2
    79
williamr@2
    80
		/** Write the entire array to a stream */
williamr@2
    81
		inline void ExternalizeL(RWriteStream& aStream) const;
williamr@2
    82
williamr@2
    83
		/** Remove an element from the array.
williamr@2
    84
		    Note that the function does not delete the pointer.
williamr@2
    85
		 */
williamr@2
    86
		inline void RemoveL(TInt aIndex);
williamr@2
    87
williamr@2
    88
	private:
williamr@2
    89
		RPointerArray <T> iArray;
williamr@2
    90
		};
williamr@2
    91
	}
williamr@2
    92
williamr@2
    93
// include inline function definitions
williamr@2
    94
#include <caf/streamableptrarray.inl>
williamr@2
    95
williamr@2
    96
#endif