systemswstubs/examplecommonisc/IscDataTransmissionBase/inc/IscBufferQueue.h
changeset 39 65e91466a14b
parent 31 931072794a66
child 40 b7e5ed8c1342
equal deleted inserted replaced
31:931072794a66 39:65e91466a14b
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Declaration of DIscBufferQueue class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef ISCBUFFERQUEUE_H
       
    21 #define ISCBUFFERQUEUE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <kernel.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // MACROS
       
    29 
       
    30 // DATA TYPES
       
    31 
       
    32 // FUNCTION PROTOTYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class DIscQueue;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  Queue class for buffer allocation and management
       
    41 *
       
    42 *  @lib IscDataTransmissionBase.LIB
       
    43 *  @since 2.8
       
    44 */
       
    45 class DIscBufferQueue 
       
    46     {
       
    47     public:  // Constructors and destructor
       
    48         
       
    49         /**
       
    50         * C++ default constructor.
       
    51         */
       
    52         DIscBufferQueue();
       
    53         
       
    54         /**
       
    55         * Construct a new queue
       
    56         * @since 2.8
       
    57         * @param  TUint16 aSize size of element in queue
       
    58         * @param TUint16 aCount amount of elements in queue
       
    59         * @param TUint8* &aCurrentAddress start address of queue
       
    60         * @return DIscBufferQueue* pointer to queue
       
    61         */
       
    62         static DIscBufferQueue* New( TUint16 aSize, TUint16 aCount, TUint8* &aCurrentAddress );
       
    63         
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         ~DIscBufferQueue();
       
    68 
       
    69     public: // New functions
       
    70         
       
    71         /**
       
    72         * Checks if queue is empty
       
    73         * @since 2.8
       
    74         * @return TBool ETrue if empty, otherwise EFalse
       
    75         */
       
    76         inline TBool Empty(){return iCount ? EFalse : ETrue;};
       
    77 
       
    78         /**
       
    79         * Reserves first element from the queue
       
    80         * @since 2.8
       
    81         * @return TDes8* pointer to element if succesful, otherwise NULL
       
    82         */
       
    83         TDes8* Reserve();
       
    84         
       
    85         /**
       
    86         * Releases element from the queue
       
    87         * @since 2.8
       
    88         * @param TDes8* aPtr pointer to element
       
    89         * @return void 
       
    90         */
       
    91         void Release( TDes8* aPtr );
       
    92 
       
    93     protected:  // New functions
       
    94         
       
    95         /**
       
    96         * Function to disable interrupts
       
    97         * @since 2.8
       
    98         * @return TInt KErrNone if succesful
       
    99         */
       
   100         TInt DisableIrqs();
       
   101 
       
   102         /**
       
   103         * Function to restore interrupts
       
   104         * @since 2.8
       
   105         * @param TInt aLevel level where interrupts should be restored
       
   106         * @return void 
       
   107         */
       
   108         void RestoreIrqs( TInt aLevel );
       
   109 
       
   110 
       
   111     protected:  // Functions from base classes
       
   112         
       
   113     private:
       
   114 
       
   115         /**
       
   116         * 2nd phase constructor
       
   117         * @since 2.8
       
   118         * @param  TUint16 aSize size of element in queue
       
   119         * @param TUint16 aCount amount of elements in queue
       
   120         * @param TUint8* &aCurrentAddress start address of queue
       
   121         * @return TInt 
       
   122         */
       
   123         TInt Construct( TUint16 aSize, TUint16 aCount, TUint8* &aCurrentAddress );
       
   124 
       
   125     public:     // Data
       
   126     
       
   127     protected:  // Data
       
   128 
       
   129     private:    // Data
       
   130 
       
   131         volatile TUint32 iCount;
       
   132         TUint32**       iBuffers;
       
   133         DIscQueue*      iBuffersQueue;  
       
   134 
       
   135     };
       
   136 
       
   137 #endif      // ISCBUFFERQUEUE_H   
       
   138             
       
   139 // End of File