servicediscoveryandcontrol/pnp/test/upnp/chunkmgr/inc/cmemchunk.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 #ifndef __CMEMCHUNK_
       
    21 #define __CMEMCHUNK_
       
    22 #include "rmemcell.h"
       
    23 
       
    24 class RMemCellList
       
    25 	{
       
    26 public:
       
    27 	RMemCellList ()
       
    28 		{
       
    29 		Init ();
       
    30 		}
       
    31 	RMemCellList ( RMemCell* aFirst, RMemCell* aLast )
       
    32 		: iNext ( aFirst ), iLast ( aLast )
       
    33 		{
       
    34 		
       
    35 		}
       
    36 	
       
    37 	void Append ( RMemCell* aPtr );
       
    38 	void Append ( RMemCellList& aList );
       
    39 	TInt Transfer ( RMemCellList& aList, TInt aSize );
       
    40 	
       
    41 	void Init ()
       
    42 		{
       
    43 		iNext = iLast = NULL;		
       
    44 		}
       
    45 	
       
    46 	TBool IsEmpty ()
       
    47 		{
       
    48 		return ( iNext == NULL ) ? ETrue : EFalse;	
       
    49 		}
       
    50 	RMemCell* First ()
       
    51 		{
       
    52 		return iNext;		
       
    53 		}
       
    54 	
       
    55 	RMemCell* Last ()
       
    56 		{
       
    57 		return iLast;
       
    58 		}
       
    59 		
       
    60 private:
       
    61 	RMemCell* iNext;
       
    62 	RMemCell* iLast;		
       
    63 	};
       
    64 
       
    65 class CMemChunk : public CBase
       
    66 	{
       
    67 public:
       
    68 	static CMemChunk* New ( CChunkAllocator& aAllocator, RChunkPool& aChunkPool, TInt aNumBlocks , TInt aBlockSize );
       
    69 	~CMemChunk ();
       
    70 	RMemCellList& List ()
       
    71 		{
       
    72 		return iQueue;
       
    73 		}
       
    74 	TInt NumBlocks ()
       
    75 		{
       
    76 		return iNumBlocks;
       
    77 		}
       
    78 		
       
    79 private:
       
    80 	CMemChunk ( CChunkAllocator& aAllocator, TInt aNumBlocks );
       
    81 	TAny* operator new (TUint aNumBlocks, TInt aExtra, CChunkAllocator& aAllocator );
       
    82 	void operator delete ( TAny* aPtr, TInt aExtra, CChunkAllocator& aAllocator );
       
    83 	void CMemChunk::operator delete ( TAny* aPtr );
       
    84 	
       
    85 private:
       
    86 	RMemCellList		iQueue;
       
    87 	CChunkAllocator&	iChunkAllocator;	
       
    88 	TUint				iNumBlocks;
       
    89 	};
       
    90 
       
    91 #endif /*__CMEMCHUNK_*/