skins/AknSkins/inc/AknsASICacheEntry.h
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Defines an internal class CAknsAppSkinInstanceCacheEntry which
       
    15 *                encapsulates a single skin instance cache entry.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef AKNSASICACHEENTRY_H
       
    21 #define AKNSASICACHEENTRY_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <AknsItemData.h>
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29 * Item data cache entry used by CAknsAppSkinInstance.
       
    30 * CAknsAppSkinInstanceCacheEntry encapsulates single cache item. It provides
       
    31 * explicit reference counting, but the caller is responsible of calling
       
    32 * appropriate methods and also destructing the cache entry when it is no longer
       
    33 * referenced.
       
    34 *
       
    35 * This is an internal class that contains no exported functions.
       
    36 * The class is not intended for derivation outside the library.
       
    37 *
       
    38 * @since 2.0
       
    39 *
       
    40 * @internal
       
    41 */
       
    42 NONSHARABLE_CLASS(CAknsAppSkinInstanceCacheEntry) : public CBase
       
    43     {
       
    44     public: // Construction and destruction
       
    45 
       
    46         /**
       
    47         * C++ constructor.
       
    48         *
       
    49         * @param aID Item ID of the new cache item.
       
    50         *
       
    51         * @param aData Pointer to item data. Ownership is transferred to
       
    52         *   CAknsAppSkinInstanceCacheEntry instance. @c NULL value is valid.
       
    53         *
       
    54         * @internal
       
    55         */
       
    56         CAknsAppSkinInstanceCacheEntry( const TAknsItemID& aID,
       
    57             CAknsItemData* aData );
       
    58 
       
    59         /**
       
    60         * Two-phased constructor.
       
    61         *
       
    62         * @param aID Item ID of the new cache item.
       
    63         *
       
    64         * @param aData Pointer to item data. Ownership is transferred to
       
    65         *   CAknsAppSkinInstanceCacheEntry instance. @c NULL value is valid.
       
    66         *
       
    67         * @return Newly constructed CAknsAppSkinInstanceCacheEntry object.
       
    68         *
       
    69         * @par Exceptions:
       
    70         *   If construction fails, leaves with an error code.
       
    71         *
       
    72         * @internal
       
    73         */
       
    74         static CAknsAppSkinInstanceCacheEntry* NewL(
       
    75             const TAknsItemID& aID, CAknsItemData* aData );
       
    76 
       
    77         /**
       
    78         * Destructor.
       
    79         * Deletes iData member.
       
    80         *
       
    81         * @internal
       
    82         */
       
    83         virtual ~CAknsAppSkinInstanceCacheEntry();
       
    84 
       
    85     public: // New functions
       
    86 
       
    87         /**
       
    88         * Returns the item ID of this cache entry.
       
    89         *
       
    90         * @return Item ID.
       
    91         *
       
    92         * @internal
       
    93         */
       
    94         inline TAknsItemID ID() const;
       
    95 
       
    96         /**
       
    97         * Returns item data associated with this cache entry.
       
    98         *
       
    99         * @return Pointer to item data. CAknsAppSkinInstanceCacheEntry still
       
   100         *   owns the item data object and controls its lifetime.
       
   101         *
       
   102         * @internal
       
   103         */
       
   104         inline CAknsItemData* Data();
       
   105 
       
   106         /**
       
   107         * Destroys the old item data (if any) and sets a new one.
       
   108         *
       
   109         * @param aData New item data to be associated with this cache entry.
       
   110         *   Ownership of item data is transferred to
       
   111         *   CAknsAppSkinInstanceCacheEntry instance.
       
   112         *
       
   113         * @internal
       
   114         */
       
   115         inline void DestroyAndSetData( CAknsItemData* aData );
       
   116 
       
   117         /**
       
   118         * Increases reference counter by one.
       
   119         *
       
   120         * @internal
       
   121         */
       
   122         void IncreaseRefCount();
       
   123 
       
   124         /**
       
   125         * Decreases reference counter by one.
       
   126         * Caller is resposible of deleting the cache item when reference count
       
   127         * drops to zero. This can be checked by calling
       
   128         * CAknsAppSkinInstanceCacheEntry::IsReferenced().
       
   129         *
       
   130         * @par Exceptions:
       
   131         *   While this function may not leave and does not delete object, it
       
   132         *   may panic if reference count becomes negative.
       
   133         *
       
   134         * @internal
       
   135         */
       
   136         void DecreaseRefCount();
       
   137 
       
   138         /**
       
   139         * Tells whether the cache item is referenced.
       
   140         *
       
   141         * @return ETrue if reference count is positive, EFalse otherwise.
       
   142         *
       
   143         * @internal
       
   144         */
       
   145         TBool IsReferenced() const;
       
   146 
       
   147         /**
       
   148         * Determines the order of two CAknsAppSkinInstanceCacheEntry objects.
       
   149         * Order is determined based on the item ID of the object, as described
       
   150         * in TAknsItemID::LinearOrder().
       
   151         *
       
   152         * @param aFirst First object to be compared.
       
   153         *
       
   154         * @param aSecond Second object to be compared.
       
   155         *
       
   156         * @return 0 if the two objects are equal, negative value if the first
       
   157         *   object is less than the second and positive value if the first
       
   158         *   object is greater than the second.
       
   159         *
       
   160         * @internal
       
   161         */
       
   162         static TInt LinearOrder(
       
   163             const CAknsAppSkinInstanceCacheEntry& aFirst,
       
   164             const CAknsAppSkinInstanceCacheEntry& aSecond );
       
   165 
       
   166     private: // Data members
       
   167 
       
   168         TAknsItemID iID;        //!< Item ID.
       
   169         TInt iRefCount;         //!< Reference counter.
       
   170         CAknsItemData* iData;   //!< Pointer to item data.
       
   171 
       
   172     };
       
   173 
       
   174 // INLINED MEMBERS
       
   175 #include "AknsASICacheEntry.inl"
       
   176 
       
   177 #endif      // AKNSASICACHEENTRY_H
       
   178 
       
   179 // End of File