menucontentsrv/enginc/menuengidmanager.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:23:10 +0200
changeset 4 1a2a00e78665
parent 0 79c6a41cd166
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

#ifndef __MENUENGIDMANAGER_H__
#define __MENUENGIDMANAGER_H__

// INCLUDES

#include <e32base.h>

// CLASS DECLARATION

/**
* Menu Engine ID manager - providing unique ID-s.
*/
NONSHARABLE_CLASS( CMenuEngIdManager ): public CBase
    {

public:     // construction

    /**
    * Destructor.
    */
    virtual ~CMenuEngIdManager();

    /**
    * Constructor.
    */
    CMenuEngIdManager();

public:     // new methods

    /**
    * Set the seed.
    * @param aSeed ID seed. Any value is suitable (does not effect
    * ID uniqueness). However, the seed is persisted between runs,
    * it provides better ID distribution (returned ID-s are reused later).
    */
    void SetSeed( TInt aSeed ) { iSeed = aSeed; }

    /**
    * Get the seed.
    * @return Seed.
    */
    TInt Seed() const { return iSeed; }

public:     // new methods

    /**
    * Generate and allocate new ID.
    * @param aId ID
    */
    void AllocL( TInt& aId );

    /**
    * Store existing ID (mark it as used).
    * No sanity check - ID-s can be added more than once!
    * @param aId ID.
    */
    void AddL( TInt aId ); // Store existing ID (==mark as used)

    /**
    * Free ID (mark it as unused). Safe to call if aId is not used.
    * @param aId ID.
    */
    void Remove( TInt aId ); // Free ID (==mark as unused)

private:    // data

    RArray<TInt> iIds; ///< Id array. Own.
    TInt iSeed; ///< Seed.

    };

#endif // __MENUENGIDMANAGER_H__