sensorservices/sensorserver/inc/server/sensrvpropertyqueue.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Property queue implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SENSRVTPROPERTYQUEUE_H
       
    20 #define SENSRVTPROPERTYQUEUE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <sensrvproperty.h>
       
    24 
       
    25 /**
       
    26  * Property queue. 
       
    27  * This class ensures that queue and queued items (TSensrvProperty)
       
    28  * are allocated from same heap.
       
    29  *
       
    30  * @since S60 5.0
       
    31  */
       
    32 class CSensrvPropertyQueue : public CBase
       
    33     {
       
    34     public:
       
    35        
       
    36         /**
       
    37         * Linkable property pointer.
       
    38         */
       
    39         class TLinkablePropertyPtr
       
    40             {
       
    41             public:
       
    42                 TLinkablePropertyPtr()
       
    43                     {
       
    44                     }
       
    45 
       
    46                 /**
       
    47                 * Link item for queueing property pointers
       
    48                 */
       
    49                 TSglQueLink iLink;
       
    50                 
       
    51                 /**
       
    52                 * Property
       
    53                 */
       
    54                 TSensrvProperty iProperty;
       
    55             };
       
    56 
       
    57 
       
    58         /**
       
    59         * Two phase constructor.       
       
    60         */
       
    61         static CSensrvPropertyQueue* NewL();
       
    62 
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~CSensrvPropertyQueue();
       
    67 
       
    68         /**
       
    69         * Adds a copy of a property to the the queue.
       
    70         *
       
    71         * @since S60 5.0
       
    72         * @param aProperty The property to be added.
       
    73         * @return Symbian OS standard error code.
       
    74         */
       
    75         TInt Append( const TSensrvProperty& aProperty );
       
    76 
       
    77         /**
       
    78         * Gets pointer to first property from queue.
       
    79         *
       
    80         * @since S60 5.0
       
    81         * @return First property in queue.
       
    82         */
       
    83         TSensrvProperty* First();
       
    84 
       
    85         /**
       
    86         * Removes and deletes first property from queue.
       
    87         *
       
    88         * @since S60 5.0
       
    89         */
       
    90         void RemoveFirst();
       
    91 
       
    92         /**
       
    93         * Removes and deletes all properties.
       
    94         *
       
    95         * @since S60 5.0
       
    96         */
       
    97         void RemoveAll();
       
    98         
       
    99         /**
       
   100         * Checks if queue is empty
       
   101         *
       
   102         * @since S60 5.0
       
   103         * @return ETrue if queue is empty.
       
   104         */
       
   105         inline TBool IsEmpty() {return iPropertyPtrList.IsEmpty(); };
       
   106         
       
   107 
       
   108     private:
       
   109 
       
   110         /**
       
   111         * C++ constructor
       
   112         */
       
   113         CSensrvPropertyQueue();
       
   114 
       
   115         /**
       
   116         * 2nd phase of construction
       
   117         *
       
   118         * @since S60 5.0
       
   119         */
       
   120         void ConstructL();            
       
   121 
       
   122     private:
       
   123     
       
   124         /**
       
   125         * Holds queued properties.
       
   126         * Queued objects are owned.
       
   127         */
       
   128         TSglQue<TLinkablePropertyPtr> iPropertyPtrList;
       
   129 
       
   130         /**
       
   131         * Iterator for property queue
       
   132         */        
       
   133         TSglQueIter<TLinkablePropertyPtr> iPropertyPtrIter;
       
   134                 
       
   135         /**
       
   136         * Heap where the queue resides. 
       
   137         * Transactions must reside in the same heap.
       
   138         * Not own.
       
   139         */
       
   140         RHeap* iHeap;
       
   141     };
       
   142 
       
   143 
       
   144 
       
   145 #endif // SENSRVTPROPERTYQUEUE_H