equal
deleted
inserted
replaced
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
55 @internalComponent */ |
55 @internalComponent */ |
56 class RCoeDynamicDataStorage |
56 class RCoeDynamicDataStorage |
57 { |
57 { |
58 public: |
58 public: |
59 RCoeDynamicDataStorage(); |
59 RCoeDynamicDataStorage(); |
60 void Open(); |
60 TInt Open(); |
61 void Close(); |
61 void Close(); |
62 TInt Count() const; |
62 TInt Count() const; |
63 void ResetCount(); |
63 void ResetCount(); |
64 void IncCount(); |
64 void IncCount(); |
65 TInt ReserveData(); |
65 TInt ReserveData(); |
96 : iIndices(~0x0), iDynamicData(NULL) // Set iIndices to all ones |
96 : iIndices(~0x0), iDynamicData(NULL) // Set iIndices to all ones |
97 { |
97 { |
98 ResetCount(); |
98 ResetCount(); |
99 } |
99 } |
100 |
100 |
101 void RCoeDynamicDataStorage::Open() |
101 TInt RCoeDynamicDataStorage::Open() |
102 { |
102 { |
103 ASSERT(!iDynamicData); |
103 ASSERT(!iDynamicData); |
104 ReserveData(); |
104 TInt err = ReserveData(); |
105 |
105 |
106 #ifdef PROFILE_MEMORY |
106 #ifdef PROFILE_MEMORY |
107 MEMORY_SAVED += KCurrentNumberOfOptionalVaraiblesInCCoeControl*sizeof(TAny*); |
107 if (err==KErrNone) |
108 MEMORY_SAVED -= sizeof(RCoeDynamicDataStorage); |
108 { |
109 #endif |
109 MEMORY_SAVED += KCurrentNumberOfOptionalVaraiblesInCCoeControl*sizeof(TAny*); |
110 } |
110 MEMORY_SAVED -= sizeof(RCoeDynamicDataStorage); |
111 |
111 } |
|
112 #endif |
|
113 |
|
114 return err; |
|
115 } |
|
116 |
112 void RCoeDynamicDataStorage::Close() |
117 void RCoeDynamicDataStorage::Close() |
113 { |
118 { |
114 #ifdef PROFILE_MEMORY |
119 #ifdef PROFILE_MEMORY |
115 MEMORY_SAVED += sizeof(RCoeDynamicDataStorage); |
120 MEMORY_SAVED += sizeof(RCoeDynamicDataStorage); |
116 if(HasReservedData()) |
121 if(HasReservedData()) |
179 return KErrNone; |
184 return KErrNone; |
180 } |
185 } |
181 |
186 |
182 inline TAny* RCoeDynamicDataStorage::Data(TInt aSlotIndex, TAny* aDefaultValue) const |
187 inline TAny* RCoeDynamicDataStorage::Data(TInt aSlotIndex, TAny* aDefaultValue) const |
183 { |
188 { |
184 if(!this) |
189 if (!this) |
185 return aDefaultValue; |
190 return aDefaultValue; |
186 |
191 |
187 const TInt dataIndex = DataIndex(aSlotIndex); |
192 const TInt dataIndex = DataIndex(aSlotIndex); |
188 if(dataIndex != KUndefinedIndex) |
193 if (dataIndex!=KUndefinedIndex && iDynamicData!=NULL) //Defensive Code |
189 return iDynamicData[dataIndex]; |
194 return iDynamicData[dataIndex]; |
190 else |
195 else |
191 return aDefaultValue; |
196 return aDefaultValue; |
192 } |
197 } |
193 |
198 |
194 inline TInt RCoeDynamicDataStorage::DataIndex(TInt aSlotIndex) const |
199 inline TInt RCoeDynamicDataStorage::DataIndex(TInt aSlotIndex) const |
195 { |
200 { |
196 const Uint64 mask = KIndexSlotMask << KIndexSlotSize*aSlotIndex; |
201 const Uint64 mask = KIndexSlotMask << KIndexSlotSize*aSlotIndex; |