menucontentsrv/enginc/menuengidmanager.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __MENUENGIDMANAGER_H__
       
    19 #define __MENUENGIDMANAGER_H__
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 /**
       
    28 * Menu Engine ID manager - providing unique ID-s.
       
    29 */
       
    30 NONSHARABLE_CLASS( CMenuEngIdManager ): public CBase
       
    31     {
       
    32 
       
    33 public:     // construction
       
    34 
       
    35     /**
       
    36     * Destructor.
       
    37     */
       
    38     virtual ~CMenuEngIdManager();
       
    39 
       
    40     /**
       
    41     * Constructor.
       
    42     */
       
    43     CMenuEngIdManager();
       
    44 
       
    45 public:     // new methods
       
    46 
       
    47     /**
       
    48     * Set the seed.
       
    49     * @param aSeed ID seed. Any value is suitable (does not effect
       
    50     * ID uniqueness). However, the seed is persisted between runs,
       
    51     * it provides better ID distribution (returned ID-s are reused later).
       
    52     */
       
    53     void SetSeed( TInt aSeed ) { iSeed = aSeed; }
       
    54 
       
    55     /**
       
    56     * Get the seed.
       
    57     * @return Seed.
       
    58     */
       
    59     TInt Seed() const { return iSeed; }
       
    60 
       
    61 public:     // new methods
       
    62 
       
    63     /**
       
    64     * Generate and allocate new ID.
       
    65     * @param aId ID
       
    66     */
       
    67     void AllocL( TInt& aId );
       
    68 
       
    69     /**
       
    70     * Store existing ID (mark it as used).
       
    71     * No sanity check - ID-s can be added more than once!
       
    72     * @param aId ID.
       
    73     */
       
    74     void AddL( TInt aId ); // Store existing ID (==mark as used)
       
    75 
       
    76     /**
       
    77     * Free ID (mark it as unused). Safe to call if aId is not used.
       
    78     * @param aId ID.
       
    79     */
       
    80     void Remove( TInt aId ); // Free ID (==mark as unused)
       
    81 
       
    82 private:    // data
       
    83 
       
    84     RArray<TInt> iIds; ///< Id array. Own.
       
    85     TInt iSeed; ///< Seed.
       
    86 
       
    87     };
       
    88 
       
    89 #endif // __MENUENGIDMANAGER_H__