javamanager/javaregistry/legacy/server/inc/uidallocator.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003, 2005-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:  Class which allocates random UIDs from a given range
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef UIDALLOCATOR_H
       
    19 #define UIDALLOCATOR_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 
       
    24 namespace Java
       
    25 {
       
    26 namespace Manager
       
    27 {
       
    28 namespace Registry
       
    29 {
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34  * This class allows clients to allocate a set of UIDs from a given range
       
    35  * @internalComponent
       
    36  * @since S60 v3.2
       
    37  */
       
    38 class TUidAllocator
       
    39 {
       
    40 public:
       
    41     /**
       
    42      * Construct a new UID allocator.
       
    43      * @param aLowerBound The lowest value which can be allocated
       
    44      * @param aUpperBound Values can be allocated up to, but not including
       
    45      * the upper bound
       
    46      * @param aUsedUids The array of already used UIDs
       
    47      * @since S60 v3.2
       
    48      */
       
    49     TUidAllocator(TUid aLowerBound, TUid aUpperBound, const RArray<TUid>& aUsedUids);
       
    50 
       
    51     /**
       
    52      * Allocates a certain number of UIDs and appends them to the array. These
       
    53      * UIDs will be contiguously allocated
       
    54      * @since S60 v3.2
       
    55      */
       
    56     void AllocateL(TInt aNumberOfUids, RArray<TUid>& aArray);
       
    57 
       
    58     /**
       
    59      * Allocates a single UID and returns it
       
    60      * @return a TUid allocated by this method
       
    61      * @since S60 v3.2
       
    62      */
       
    63     TUid AllocateL();
       
    64 
       
    65 private: //Data
       
    66 
       
    67     /**
       
    68      * The lowest value which can be allocated
       
    69      * @since S60 v3.2
       
    70      */
       
    71     TInt32 iLowerBound;
       
    72 
       
    73     /**
       
    74      * Values can be allocated up to, but not including
       
    75      * the upper bound
       
    76      * @since S60 v3.2
       
    77      */
       
    78     TInt32 iUpperBound;
       
    79 
       
    80     /**
       
    81      * The array of already used UIDs
       
    82      * @since S60 v3.2
       
    83      */
       
    84     const RArray<TUid>& iUsedUids;
       
    85 
       
    86     /**
       
    87      * Seed for the random number generator
       
    88      * @since S60 v3.2
       
    89      */
       
    90     TInt64 iSeed;
       
    91 };
       
    92 
       
    93 }//namespace Registry
       
    94 }//namespace Manager
       
    95 }//namespace Java
       
    96 
       
    97 #endif // UIDALLOCATOR_H
       
    98 
       
    99 // End of File
       
   100