hti/HtiFramework/inc/HtiMessageQueue.h
branchRCL_3
changeset 59 8ad140f3dd41
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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 "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:  Simple FIFO Queue class based on single-linked list
       
    15 *        (TSglQue<CHtiMessage>). It alsoe provides functionality
       
    16 *        to monitor memory allocated by all messages.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef MESSAGEQUEUE_H__
       
    22 #define MESSAGEQUEUE_H__
       
    23 
       
    24 #include "HtiMessage.h"
       
    25 
       
    26 NONSHARABLE_CLASS(CHtiMessageQueue)  : public CBase
       
    27     {
       
    28 public:
       
    29     /**
       
    30     * Create a new queue
       
    31     *
       
    32     */
       
    33     static CHtiMessageQueue* NewL();
       
    34 
       
    35     virtual ~CHtiMessageQueue();
       
    36 
       
    37     /**
       
    38     * Adds a new message to the queue
       
    39     *
       
    40     * @param aMessage instance of ready HTI message
       
    41     */
       
    42     void Add(CHtiMessage& aMessage);
       
    43 
       
    44     /**
       
    45     * Retrives a message from the queue
       
    46     * and remove it from the queue
       
    47     *
       
    48     * @return a HTI message
       
    49     */
       
    50     CHtiMessage* Remove();
       
    51 
       
    52     /**
       
    53     * Removes specifeda message from the queue
       
    54     *
       
    55     * @param aMsg message to remove
       
    56     * @return a HTI message
       
    57     */
       
    58     CHtiMessage* Remove( CHtiMessage* aMsg);
       
    59 
       
    60     /**
       
    61     * Deletes all messages from queue
       
    62     */
       
    63     void RemoveAll();
       
    64 
       
    65     /**
       
    66     * Starts iteration based on service names
       
    67     * Each call to GetNext() will return next message to the service
       
    68     * different from the service name in the current message
       
    69     */
       
    70     void StartServiceIteration();
       
    71 
       
    72     /**
       
    73     * Returns next message with service name different
       
    74     * than in the current message.
       
    75     * This method does not remove message from the queue, so ownership
       
    76     * is not transfered. Remove( CHtiMessage* aMsg) should be used
       
    77     * to delete the message from a queue.
       
    78     *
       
    79     * @return a HTI message or NULL if there is no messages anymore
       
    80     */
       
    81     CHtiMessage* GetNext();
       
    82 
       
    83 
       
    84     /**
       
    85     * Checks that the queue is empty
       
    86     *
       
    87     * @return ETrue if queue is empty
       
    88     */
       
    89     TBool IsEmpty() const;
       
    90 
       
    91     /**
       
    92     * Returns memory allocated by all messages in the queue
       
    93     */
       
    94     TInt QueueSize() const;
       
    95 
       
    96 protected:
       
    97     CHtiMessageQueue();
       
    98 
       
    99 protected:
       
   100     /**
       
   101     * Queue
       
   102     */
       
   103     TSglQue<CHtiMessage> iQueue;
       
   104 
       
   105     /**
       
   106     * Current memory allocated by hti messages in the queue
       
   107     */
       
   108     TInt iMemoryAllocated;
       
   109 
       
   110     /**
       
   111     * queue iterator
       
   112     */
       
   113     TSglQueIter<CHtiMessage> iQueueIter;
       
   114 
       
   115     /**
       
   116     * last service uid
       
   117     * used during iteration by service names
       
   118     */
       
   119     TUid iLastServiceUid;
       
   120 
       
   121     /**
       
   122     * Used to ommit service name checking for the first GetNext()
       
   123     */
       
   124     TBool iIsFirst;
       
   125     };
       
   126 
       
   127 #endif