usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/pktdrv/inc/ncmbuffermanager.h
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 // Copyright (c) 2010 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 the License "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 
       
    17 
       
    18 /**
       
    19 @file
       
    20 @internalComponent
       
    21 */
       
    22 
       
    23 
       
    24 #ifndef NCMBUFFERMANAGER_H
       
    25 #define NCMBUFFERMANAGER_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include "ncmpktdrvcommon.h"
       
    29 
       
    30 
       
    31 
       
    32 /**
       
    33 Responsible for share chunk buffer managerment
       
    34 */
       
    35 
       
    36 NONSHARABLE_CLASS(CNcmBufferManager) : public CBase
       
    37 
       
    38     {
       
    39 public:
       
    40     static CNcmBufferManager* NewL();
       
    41     ~CNcmBufferManager();
       
    42     /**
       
    43     * get a free buffer block
       
    44     *
       
    45     * @param aBuffer to store the buffer block
       
    46     * @return KErrNone        if success
       
    47     *         KErrCongestion  if there is not enough buffer block, should start flow control
       
    48     */
       
    49     TInt GetBuffer(TNcmBuffer& aBuffer);
       
    50     /**
       
    51     * free a buffer block
       
    52     *
       
    53     * @param aBuffer store the buffer block to free
       
    54     */
       
    55     void FreeBuffer(const TNcmBuffer& aBuffer);
       
    56     void InitBufferArea(TAny* aBuf, TInt aLength);
       
    57     /**
       
    58     * get a free buffer block
       
    59     *
       
    60     * @param aSize new ntb size
       
    61     * @return KErrNone        if success
       
    62     *         KErrUnknown  if too big ntb size, can't create enought buffer block
       
    63     */    
       
    64     TInt SetBufferCellSize(TInt aSize);
       
    65     TBool IsCongestion();
       
    66     TInt RequiredBufferCount();	
       
    67     inline void SetAlignSize(TInt aSize);	
       
    68     inline TInt FreeBufferCount();		
       
    69 
       
    70 private:
       
    71     CNcmBufferManager();
       
    72 
       
    73 private:
       
    74     /**
       
    75     * array of free buffer blocks 
       
    76     */
       
    77     RArray<TNcmBuffer> iFreeQueue;
       
    78     /**
       
    79     * share chunk LDD buffer area 
       
    80     */
       
    81     TUint8*            iBuf;
       
    82     TInt               iLen;
       
    83     TInt               iCellSize;
       
    84     TInt               iAlignSize;	
       
    85     /**
       
    86     * there is enough buffer blocks or not 
       
    87     */
       
    88     TBool              iIsCongestion;
       
    89     
       
    90     };
       
    91 
       
    92 inline void CNcmBufferManager::SetAlignSize(TInt aSize)
       
    93     {
       
    94     iAlignSize = aSize;
       
    95     }
       
    96 
       
    97 inline TInt CNcmBufferManager::FreeBufferCount()
       
    98     {
       
    99     return iFreeQueue.Count();
       
   100     }
       
   101 
       
   102 
       
   103 #endif    //NCMBUFFERMANAGER_H
       
   104