|
1 /* |
|
2 * Copyright (c) 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: Array of fixed size elements on global chunk |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef RMPXFIXEDARRAY_H |
|
21 #define RMPXFIXEDARRAY_H |
|
22 |
|
23 #include "mpxheapmanager.h" |
|
24 |
|
25 /** |
|
26 * Base class for fixed arrays on global heap; not for direct use |
|
27 */ |
|
28 class RMPXFixedArrayBase |
|
29 { |
|
30 public: |
|
31 /** |
|
32 * Returns pointer to start of Array (buffer holding array items) |
|
33 * |
|
34 * @param aClientHandle, client handle to the global chunk |
|
35 * @return raw data of the array |
|
36 */ |
|
37 inline TAny* Buf(TUint aClientHandle) const; |
|
38 |
|
39 /** |
|
40 * Number of elements in array |
|
41 * |
|
42 * @return number of elements in array |
|
43 */ |
|
44 inline TInt Count() const; |
|
45 |
|
46 /** |
|
47 * Frees resources; object can go out of scope |
|
48 * |
|
49 * @param aClientHandle, client handle to the global chunk |
|
50 */ |
|
51 |
|
52 inline void Close(TUint aClientHandle); |
|
53 |
|
54 /** |
|
55 * Delete's content; array can be reused |
|
56 * |
|
57 * @param aClientHandle, client handle to the global chunk |
|
58 */ |
|
59 void Reset(TUint aClientHandle); // Frees contents |
|
60 |
|
61 /** |
|
62 * Copies the contents of aArray into this array |
|
63 * |
|
64 * @param aClientHandle, client handle to the global chunk |
|
65 * @param aArray, source array |
|
66 * @return KErrNone if succeeded, otherwise system error code |
|
67 */ |
|
68 TInt Copy(TUint aClientHandle,const RMPXFixedArrayBase& aArray); |
|
69 |
|
70 /** |
|
71 * Allocates buffer for an array of aCount items, each of size |
|
72 * aElementSize; returns pointer to start of buffer |
|
73 * |
|
74 * @param aClientHandle, client handle to the global chunk |
|
75 * @param aCount, number of the element in the array |
|
76 * @return address of memory allocated |
|
77 */ |
|
78 TAny* Alloc(TUint aClientHandle,TInt aCount); |
|
79 |
|
80 protected: |
|
81 RMPXFixedArrayBase(); |
|
82 |
|
83 /** |
|
84 * Constructor. |
|
85 * @param aElementSize size of the array element |
|
86 */ |
|
87 RMPXFixedArrayBase(TInt aElementSize); |
|
88 |
|
89 /** |
|
90 * Constructor: copies content from aArray |
|
91 * |
|
92 * @param aArray source array |
|
93 */ |
|
94 RMPXFixedArrayBase(const RMPXFixedArrayBase& aArray); |
|
95 |
|
96 private: |
|
97 TInt iCount; |
|
98 TInt iDataOffset; |
|
99 TInt iElementSize; |
|
100 }; |
|
101 |
|
102 /** |
|
103 * Array of fixed number of objects of type T |
|
104 */ |
|
105 template <class T> |
|
106 class RMPXFixedArray : public RMPXFixedArrayBase |
|
107 { |
|
108 public: |
|
109 /** |
|
110 * C++ default constructor. |
|
111 */ |
|
112 inline RMPXFixedArray(); |
|
113 |
|
114 /** |
|
115 * Copy constructor: copies all data from aArray into |
|
116 * this object |
|
117 */ |
|
118 inline RMPXFixedArray(const RMPXFixedArray& aArray); |
|
119 public: |
|
120 /** |
|
121 * Copies the contents of aArray into this array |
|
122 */ |
|
123 inline TInt Copy(TUint aClientHandle,const TArray<T>& aArray); |
|
124 |
|
125 /** |
|
126 * Returns array |
|
127 */ |
|
128 inline TArray<T> Array(TUint aClientHandle) const; |
|
129 |
|
130 private: |
|
131 /** |
|
132 * Count function for TArray |
|
133 */ |
|
134 inline static TInt CountFunctionR(const CBase* aThis); |
|
135 |
|
136 /** |
|
137 * At function for TArray |
|
138 */ |
|
139 inline static const TAny* AtFunctionR(const CBase* aThis,TInt aIndex); |
|
140 }; |
|
141 |
|
142 #include "mpxfixedarray.inl" |
|
143 |
|
144 #endif // RMPXFIXEDARRAY_H |