commsfwutils/commsbufs/mbufmgr/inc/mbufchain.inl
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 #if !defined(__MBufChain_inl__)
       
    17 #define __MBufChain_inl__
       
    18 
       
    19 //
       
    20 // MBUF CHAIN
       
    21 //
       
    22 
       
    23 /**
       
    24 Constructor
       
    25 */
       
    26 inline RMBufChain::RMBufChain()
       
    27 	{}
       
    28 
       
    29 /**
       
    30 Constructor
       
    31 */
       
    32 inline RMBufChain::RMBufChain(RCommsBuf* aChain) : RCommsBufChain(aChain)
       
    33 	{}
       
    34 
       
    35 
       
    36 /**
       
    37 Rerurns the first in the chain
       
    38 @return the first in the chain
       
    39 */
       
    40 inline RMBuf* RMBufChain::First()
       
    41 { return static_cast<RMBuf*>(iNext); }
       
    42 
       
    43 /**
       
    44 Returns the first in the chain
       
    45 @return the first in the chain
       
    46 */
       
    47 inline const RMBuf* RMBufChain::First() const
       
    48 { return static_cast<const RMBuf*>(iNext); }
       
    49 
       
    50 /**
       
    51 operator =
       
    52 */
       
    53 inline RMBufChain& RMBufChain::operator =(RMBuf* aChain)
       
    54 	{ iNext = aChain; return *this; }
       
    55 
       
    56 /**
       
    57 Initializes the members (iNext = NULL)
       
    58 */
       
    59 inline void RMBufChain::Init()
       
    60 	{ iNext = NULL; }
       
    61 
       
    62 inline TBool RMBufChain::IsEmpty() const
       
    63 /**
       
    64 Check if empty, if empty returns true
       
    65 */
       
    66 	{
       
    67 	return RCommsBufChain::IsEmpty();
       
    68 	}
       
    69 
       
    70 #ifndef __KERNEL_MODE__
       
    71 /**
       
    72 Links a chain to the chain in the chain
       
    73 @param aChain The chain to be linked
       
    74 */
       
    75 inline void RMBufChain::Link(RMBufChain &aChain)
       
    76 	{ if (!IsEmpty()) (static_cast<RMBuf*>(iNext))->LinkPkt(aChain); }
       
    77 
       
    78 /**
       
    79 Unlink the nfirst in the chain
       
    80 */
       
    81 inline void RMBufChain::Unlink()
       
    82 	{ if (!IsEmpty()) (static_cast<RMBuf*>(iNext))->UnlinkPkt(); }
       
    83 
       
    84 /**
       
    85 Returns next in the chain if there is next else returns the current
       
    86 */
       
    87 inline RMBufChain& RMBufChain::Next()
       
    88 	{ return IsEmpty() ? *this : (static_cast<RMBuf*>(iNext))->NextPkt(); }
       
    89 
       
    90 /**
       
    91 Returns next in the chain if there is next else returns the current
       
    92 */
       
    93 inline const RMBufChain& RMBufChain::Next() const
       
    94 	{ return IsEmpty() ? *this : (static_cast<RMBuf*>(iNext))->NextPkt(); }
       
    95 
       
    96 /** 	  	 
       
    97 Goto specified byte offset into an Mbuf chain. Used as part of copyin/out, split etc to position 	  	 
       
    98 MBuf pointer and offset from start of iBuffer. 	  	 
       
    99 @param aOffset The offset 	  	 
       
   100 @param resBuf result buffer 	  	 
       
   101 @param resOffset result offset 	  	 
       
   102 @param resLength result length 	  	 
       
   103 @param resPrevBuf result previous Buf in the chain 	  	 
       
   104 @return ETrue if successful 	  	 
       
   105 */
       
   106 inline TBool RMBufChain::Goto(TInt aOffset, RMBuf* &resBuf, TInt& resOffset, TInt& resLength) const
       
   107 	{
       
   108 	 RMBuf* prev;  return Goto(aOffset, resBuf, resOffset, resLength, prev);
       
   109 	}
       
   110 
       
   111 inline TInt RMBufChain::Copy(RMBufChain& newChain) const
       
   112     {
       
   113     return Copy(newChain, 0, KMBufAll, 0);
       
   114     }
       
   115 
       
   116 inline TInt RMBufChain::Copy(RMBufChain& newChain, TInt aOffset) const
       
   117     {
       
   118     return Copy(newChain, aOffset, KMBufAll, 0);
       
   119     }
       
   120 
       
   121 inline TInt RMBufChain::Copy(RMBufChain& newChain, TInt aOffset, TInt aLen) const
       
   122 	{
       
   123 	return Copy(newChain, aOffset, aLen, 0);
       
   124 	}
       
   125 
       
   126 #endif // KERNEL_MODE
       
   127 
       
   128 #endif // __MBufChain_inl__