|
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 // INCLUDE FILES |
|
19 |
|
20 #include "menuengidmanager.h" |
|
21 |
|
22 // ================= MEMBER FUNCTIONS ======================= |
|
23 |
|
24 // --------------------------------------------------------- |
|
25 // CMenuEngIdManager::~CMenuEngIdManager |
|
26 // --------------------------------------------------------- |
|
27 // |
|
28 CMenuEngIdManager::~CMenuEngIdManager() |
|
29 { |
|
30 iIds.Close(); |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------- |
|
34 // CMenuEngIdManager::CMenuEngIdManager |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CMenuEngIdManager::CMenuEngIdManager() |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CMenuEngIdManager::AllocL |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 void CMenuEngIdManager::AllocL( TInt& aId ) |
|
46 { |
|
47 TInt id = 0; |
|
48 TInt startSeed = iSeed; |
|
49 do |
|
50 { |
|
51 iSeed++; |
|
52 if ( iSeed == startSeed ) |
|
53 { |
|
54 // No more free IDs. This happens when we used ALL possible |
|
55 // integer numbers. (4GB of memory used for the ID-s only!) |
|
56 // Happy coverage testing! ;) |
|
57 User::Leave( KErrNoMemory ); |
|
58 } |
|
59 if ( KErrNotFound == iIds.FindInOrder( iSeed ) ) |
|
60 { |
|
61 id = iSeed; |
|
62 } |
|
63 } |
|
64 while ( !id ); |
|
65 iIds.InsertInOrderL( id ); |
|
66 aId = id; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CMenuEngIdManager::AddL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CMenuEngIdManager::AddL( TInt aId ) |
|
74 { |
|
75 if ( aId && KErrNotFound == iIds.FindInOrder( aId ) ) |
|
76 { |
|
77 iIds.InsertInOrderL( aId ); |
|
78 } |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CMenuEngIdManager::Remove |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 void CMenuEngIdManager::Remove( TInt aId ) |
|
86 { |
|
87 TInt i = iIds.FindInOrder( aId ); |
|
88 if ( KErrNotFound != i ) |
|
89 { |
|
90 iIds.Remove( i ); |
|
91 } |
|
92 } |
|
93 |
|
94 // End of File |