wim/WimServer/inc/WimMemMgmt.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  WIM memomy management
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CWIMMEMMGMT_H
       
    21 #define CWIMMEMMGMT_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "Wimi.h"            //WIMI definitions
       
    25 #include <e32base.h>
       
    26 
       
    27 
       
    28 // DATA TYPES
       
    29 enum TWimRefType
       
    30     {
       
    31     EWimiRefpt,
       
    32     EWimiRefListt,
       
    33     };
       
    34 
       
    35 struct TWimiAllocRef
       
    36     {
       
    37     union 
       
    38         {
       
    39         WIMI_Ref_pt ref;
       
    40         WIMI_RefList_t refLst;
       
    41         };
       
    42     
       
    43     TWimRefType refType;
       
    44     };
       
    45 
       
    46 
       
    47 // CLASS DECLARATION
       
    48 
       
    49 /**
       
    50 *  WIM memomy management.
       
    51 *  
       
    52 *  @since Series60 2.1
       
    53 */
       
    54 class CWimMemMgmt : public CBase
       
    55     {
       
    56     public:  // Constructors and destructor
       
    57         
       
    58         /**
       
    59         * Two-phased constructor.
       
    60         */
       
    61         static CWimMemMgmt* NewL();
       
    62         
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~CWimMemMgmt();
       
    67 
       
    68     public: // New functions
       
    69         
       
    70         /**
       
    71         * Sets active memory reference to iWimRef member variable.
       
    72         * @param aRef active reference.
       
    73         */
       
    74         void SetWIMRef( WIMI_Ref_pt aRef );
       
    75 
       
    76         /**
       
    77         * Retrieves active reference.
       
    78         * @return Active reference.
       
    79         */
       
    80         WIMI_Ref_pt WimRef();
       
    81 
       
    82         /**
       
    83         * Creates and append a new WIMI_Alloc_Ref item to iRefs array.
       
    84         * @param aLst reference list where to add the new item.
       
    85         */
       
    86         void AppendWIMRefLstL( WIMI_RefList_t aLst );
       
    87 
       
    88         /**
       
    89         * Creates and appends a new WIMI_Alloc_Ref item to iRefs array.
       
    90         * @param aRef Reference to be added.
       
    91         */
       
    92         void AppendWIMRefL( WIMI_Ref_pt aRef );        
       
    93         
       
    94         /**
       
    95         * Removes reference from the list and releases allocated memory.
       
    96         * @param aRef Reference to be freed.
       
    97         */
       
    98         void FreeRef( WIMI_Ref_pt );
       
    99 
       
   100         /**
       
   101         * Frees the reference(s) pointed by a client.
       
   102         * @param aMessage Encapsulates a client request.
       
   103         */
       
   104         void FreeWIMRefs( const RMessage2& aMessage );
       
   105 
       
   106         /**
       
   107         * Frees the list of reference(s) pointed by a client.
       
   108         * @param aMessage Encapsulates a client request.
       
   109         */
       
   110         void FreeRefLst( const RMessage2& aMessage );
       
   111 
       
   112         /**
       
   113         * Checks if the reference is valid
       
   114         * @param aRef Reference to be checked.
       
   115         * @return TBool ETrue if aRef is valid.
       
   116         */
       
   117         TBool ValidateWIMRefL( WIMI_Ref_pt aRef );
       
   118 
       
   119 
       
   120     private:
       
   121 
       
   122         CWimMemMgmt();
       
   123         void ConstructL();
       
   124         void CleanUp();
       
   125 
       
   126     private:    // Data
       
   127         RPointerArray<TWimiAllocRef> iRefs;
       
   128         WIMI_Ref_pt iWimRef;
       
   129     };
       
   130 
       
   131 #endif      // CWIMMEMMGMT_H
       
   132             
       
   133 // End of File