|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Definition of object index class |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __WSOBJIX_H__ |
|
19 #define __WSOBJIX_H__ |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 |
|
24 class CWsObject; |
|
25 |
|
26 /** |
|
27 A simple structure to hold a CWsObject and the associated handle. |
|
28 |
|
29 @internalComponent |
|
30 @released |
|
31 */ |
|
32 class TWsObject |
|
33 { |
|
34 public: |
|
35 enum |
|
36 { |
|
37 ESlotMask=0x0000FFFF, //The handle on the client side uses these 16 bits to store the slot position |
|
38 ECountMask=0x7FFF0000, //These 15 bits are used to keep a unique number (the slot reuse count) |
|
39 ETypeMask=ESlotMask, //The handle on the server side uses these 16 bits to store the type of the object |
|
40 ECountPosition=16, |
|
41 ECountBits=15, |
|
42 ECountInc=1<<ECountPosition, |
|
43 ECountWrapAround=1<<ECountBits, |
|
44 }; |
|
45 public: |
|
46 inline TWsObject(CWsObject* aObject,TInt aHandle); |
|
47 public: |
|
48 CWsObject* iObject; |
|
49 TUint iHandle; |
|
50 }; |
|
51 |
|
52 /** |
|
53 An array of CWsObject instances and their handles. |
|
54 |
|
55 Each client session maintains a list of the objects it owns. |
|
56 |
|
57 Note that the first item in the iObjectArray array is a dummy item. This is because part of the |
|
58 handle is used as an index in the array and we want to avoid index 0 because a null handle has a special |
|
59 meaning. |
|
60 |
|
61 @see CWsClient |
|
62 @internalComponent |
|
63 @released |
|
64 */ |
|
65 class CWsObjectIx : public CBase |
|
66 { |
|
67 public: |
|
68 CWsObjectIx(); |
|
69 ~CWsObjectIx(); |
|
70 void ConstructL(); |
|
71 TInt AddL(CWsObject* anObj); |
|
72 void Remove(const TWsObject* aObject); |
|
73 void Remove(CWsObject* anObj); |
|
74 CWsObject* HandleToObject(TInt aHandle) const; |
|
75 inline const CWsObject* At(TInt aPos) const; |
|
76 const TWsObject* FirstObject() const; |
|
77 TInt At(const CWsObject* anObj); |
|
78 void Tidy(); |
|
79 TInt Count() const; // Count of non NULL objects in the array |
|
80 TInt Length() const; // Length of array including empty slots |
|
81 private: |
|
82 CArrayFixFlat<TWsObject> iObjectArray; |
|
83 TInt iNewObjectCount; |
|
84 }; |
|
85 |
|
86 |
|
87 // |
|
88 // inlines // |
|
89 // |
|
90 |
|
91 // |
|
92 // TWsObject |
|
93 // |
|
94 inline TWsObject::TWsObject(CWsObject* aObject,TInt aHandle) :iObject(aObject), iHandle(aHandle) {} |
|
95 // |
|
96 // CWsObjectIx |
|
97 // |
|
98 inline const CWsObject* CWsObjectIx::At(TInt aPos) const |
|
99 {return iObjectArray[aPos].iObject;} |
|
100 #endif |