wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/wllddcircularbuffer.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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 the RWlanLddCircularBuffer class.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 2 %
       
    20 */
       
    21 
       
    22 #ifndef R_WLANCIRCULARBUFFER_H
       
    23 #define R_WLANCIRCULARBUFFER_H
       
    24 
       
    25 class TDataBuffer;
       
    26 
       
    27 /**
       
    28  * Wlan LDD Shared Memory FIFO queue for Tx packets.
       
    29  * 
       
    30  * @param size The size of the queue in packets.
       
    31  */
       
    32 template <TUint size>
       
    33 class RWlanCircularBuffer
       
    34     {
       
    35 public:
       
    36 
       
    37     /* Because this class is mapped into shared memory, it does not have
       
    38      * a constructor or a desctructor.
       
    39      */ 
       
    40 
       
    41     /**
       
    42      * Initialization. This method acts as a contructor.
       
    43      */ 
       
    44     inline void DoInit();
       
    45 
       
    46     /**
       
    47      * Release. This method acts as a desctructor.
       
    48      */ 
       
    49     inline void Release();
       
    50     
       
    51     /**
       
    52      * This method returns and removes the next packet from the queue.
       
    53      * 
       
    54      * @return Pointer to the meta header attached to the packet on success.
       
    55      *         NULL if the queue is empty.
       
    56      */ 
       
    57     inline TDataBuffer* GetPacket();
       
    58    
       
    59     /**
       
    60      * This method is used to put a packet to the end of the queue.
       
    61      * 
       
    62      * @param aPacket Pointer to the meta header attached to the packet.
       
    63      * @return ETrue if the Packet was added to the queue.
       
    64      *         EFalse if the queue was already full and the Packet could not
       
    65      *         be added to the queue.
       
    66      */ 
       
    67     inline TBool PutPacket( TDataBuffer* aPacket );
       
    68     
       
    69     /**
       
    70      * Returns the next packet in the queue without removing it from the queue.
       
    71      * 
       
    72      * @return Pointer to the meta header attached to the packet on the top 
       
    73      *         of the queue.
       
    74      */
       
    75     inline TDataBuffer* PeekPacket();
       
    76 
       
    77     /**
       
    78      * Returns the number of packets in the queue.
       
    79      * 
       
    80      * @return number of packets in the queue.
       
    81      */
       
    82     inline TUint GetLength() const;
       
    83     
       
    84     /**
       
    85      * This method can be used to check if the queue is empty.
       
    86      * 
       
    87      * @return ETrue, when the queue is empty.
       
    88      *         EFalse, when the queue is not empty.
       
    89      */ 
       
    90     inline TBool IsEmpty() const;
       
    91 
       
    92     /**
       
    93      * This method can be used to check if the queue is full.
       
    94      * 
       
    95      * @return ETrue, when the queue is full.
       
    96      *         EFalse, when the queue is not full.
       
    97      */ 
       
    98     inline TBool IsFull() const ;
       
    99     
       
   100     /**
       
   101      * This method can be used to check if the queue is active.
       
   102      * 
       
   103      * @param aTimeNow Current time as microseconds since midnight, January 
       
   104      *        1st, 0 AD nominal Gregorian
       
   105      * @return ETrue, if the queue is active.
       
   106      *         EFalse, if the queue is not active.
       
   107      */ 
       
   108     inline TBool IsActive( TInt64 aTimeNow ) const;
       
   109     
       
   110 private:    // Data
       
   111     
       
   112     /** Queue as a circular buffer */
       
   113     TDataBuffer* iBuffer[size];
       
   114     
       
   115     /** Index of the packet to get next. See GetPacket() */
       
   116     TUint iGetIndex;
       
   117     
       
   118     /** Index where to put the next packet. See PutPacket() */
       
   119     TUint iPutIndex;
       
   120     
       
   121     /** The number of packets currently in the queue */
       
   122     TUint iPacketAmount;
       
   123    
       
   124     /** The capacity of the queue */
       
   125     TUint iSize;
       
   126     
       
   127     /** 
       
   128     * Time stamp (as microseconds since midnight, January 1st, 0 AD nominal
       
   129     * Gregorian) when the queue became empty. 
       
   130     * Valid only if the queue is empty 
       
   131     */
       
   132     TInt64 iBecameEmptyAt;
       
   133 };
       
   134 
       
   135 #ifdef __KERNEL_MODE__
       
   136 
       
   137 #include "wllddcircularbuffer.inl"
       
   138 
       
   139 #endif
       
   140 
       
   141 #endif /* R_WLANCIRCULARBUFFER_H */