servicediscoveryandcontrol/pnp/test/upnp/chunkmgr/inc/rmemcell.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 #ifndef __RMEMCELL_H_
       
    20 #define __RMEMCELL_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class RChunkPool;
       
    25 
       
    26 class RMemCell
       
    27 	{
       
    28 public:
       
    29 	RMemCell ( RChunkPool* aChunkPool, TUint8* aBuffer, TInt aBlockSize );	
       
    30 	
       
    31 	
       
    32 	inline TUint8* Ptr ();
       
    33 	
       
    34 	void Free ();
       
    35 	
       
    36 	TAny* operator new ( TUint aSize, RMemCell* aPtr );
       
    37 	void operator delete (  TAny* aPtr, RMemCell* aMemCell );
       
    38 	
       
    39 	inline TUint Size ();
       
    40 	inline TUint8* Buffer();
       
    41 	inline TInt Length() const;
       
    42 	inline void SetOffset(TInt aOffset);
       
    43 	inline TInt Offset() const;
       
    44 	inline void SetData(TInt aOffset, TInt aLength);
       
    45 	inline void Unlink();
       
    46 	inline void Link(RMemCell* aBuf);
       
    47 	inline RMemCell* Next ();
       
    48 	RChunkPool* Pool ();	
       
    49 	IMPORT_C RMemCell* Last();
       
    50 	
       
    51 	inline void SetLength ( TInt aLength );
       
    52 	
       
    53 private:
       
    54 	TUint8* const 	iBuffer;
       
    55 	RChunkPool* 	iChunkPool;
       
    56 	const TInt 		iMaxSize;
       
    57 	TInt 			iOffset;
       
    58 	TInt			iLength;	
       
    59 	RMemCell*		iNextCell;
       
    60 	};
       
    61 
       
    62 TUint RMemCell::Size ()	
       
    63 	{
       
    64 	return iMaxSize;
       
    65 	}
       
    66 
       
    67 inline TUint8* RMemCell::Buffer()
       
    68 	{ 
       
    69 	return iBuffer;
       
    70 	}
       
    71 
       
    72 inline TInt RMemCell::Length() const
       
    73 	{ 
       
    74 	return iLength; 
       
    75 	}
       
    76 
       
    77 inline void RMemCell::SetOffset(TInt aOffset)
       
    78 	{ 
       
    79 	iOffset = aOffset; 
       
    80 	}
       
    81 
       
    82 inline TInt RMemCell::Offset() const
       
    83 	{ 
       
    84 	return iOffset; 
       
    85 	}
       
    86 
       
    87 inline void RMemCell::Unlink()
       
    88 	{ 
       
    89 	iNextCell = NULL; 
       
    90 	}
       
    91 
       
    92 inline void RMemCell::SetData(TInt aOffset, TInt aLength)
       
    93 	{ 
       
    94 	SetOffset(aOffset);  
       
    95 	SetLength(aLength); 
       
    96 	}
       
    97 
       
    98 inline void RMemCell::SetLength ( TInt aLength )
       
    99 	{
       
   100 	iLength = aLength;
       
   101 	}
       
   102 
       
   103 inline TUint8* RMemCell::Ptr ()
       
   104 	{
       
   105 	return iBuffer+iOffset;
       
   106 	}
       
   107 
       
   108 inline void RMemCell::Link(RMemCell* aBuf)
       
   109 	{ 
       
   110 	iNextCell = aBuf; 
       
   111 	}
       
   112 	
       
   113 inline RMemCell* RMemCell::Next ()
       
   114 	{
       
   115 	return iNextCell;
       
   116 	}
       
   117 
       
   118 
       
   119 #endif /*__RMEMCELL_H_*/