1 /* |
|
2 * Copyright (c) 2005-2007 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: Declares main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_COLLECTION_H |
|
20 #define C_COLLECTION_H |
|
21 |
|
22 #include <e32std.h> |
|
23 |
|
24 class CField; |
|
25 |
|
26 |
|
27 /** |
|
28 * Collection of HID report descriptor |
|
29 * A CCollection represents an individual collection within a HID |
|
30 * report descriptor. Each collection may have a number of associated |
|
31 * report fields (CField objects) and a number of child collection |
|
32 * objects. The collections within a HID report descriptor form a tree |
|
33 * structure, with a CReportRoot collection at the root. The tree is |
|
34 * generated by CParser. |
|
35 * |
|
36 * |
|
37 * @lib generichid.lib |
|
38 * @since S60 v5.0 |
|
39 */ |
|
40 class CCollection : public CBase |
|
41 { |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * An enumerations giving the possible types of collection, as |
|
47 * given in "USB Device Class Definition for Human Interface |
|
48 * Devices (HID)", Firmware Specification, Version 1.11, USB |
|
49 * Implementers' Forum, June 2001. |
|
50 * |
|
51 * Note that a TUint32 is used for CCollection::iType, as it is |
|
52 * possible to have a vendor defined collection type that isn't |
|
53 * included in this list. |
|
54 */ |
|
55 enum TType |
|
56 { |
|
57 EPhysical = 0x00, //!< Physical (group of axes) |
|
58 EApplication = 0x01, //!< Application (mouse,keyboard) |
|
59 ELogical = 0x02, //!< Logical (interrelated data) |
|
60 EReport = 0x03, //!< Report |
|
61 ENamedArray = 0x04, //!< NamedArray |
|
62 EUsageSwitch = 0x05, //!< UsageSwitch |
|
63 EUsageModifier = 0x06 //!< UsageModifier |
|
64 }; |
|
65 |
|
66 static CCollection* NewL(); |
|
67 static CCollection* NewLC(); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CCollection(); |
|
73 |
|
74 /** |
|
75 * Get collection type |
|
76 * |
|
77 * @since S60 v5.0 |
|
78 * @return The type for this collection item |
|
79 */ |
|
80 IMPORT_C TUint32 Type() const; |
|
81 |
|
82 /** |
|
83 * Get usagepage |
|
84 * |
|
85 * @since S60 v5.0 |
|
86 * @return The usage page for this collection |
|
87 */ |
|
88 IMPORT_C TInt UsagePage() const; |
|
89 |
|
90 /** |
|
91 * Get usagepage |
|
92 * |
|
93 * @since S60 v5.0 |
|
94 * @return The usage page for this collection |
|
95 */ |
|
96 IMPORT_C TInt Usage() const; |
|
97 |
|
98 /** |
|
99 * Get number of collections |
|
100 * |
|
101 * @since S60 v5.0 |
|
102 * @return The number of collections that have been created so far |
|
103 */ |
|
104 IMPORT_C TInt CollectionCount() const; |
|
105 |
|
106 /** |
|
107 * Gets numbers of field stored in collection |
|
108 * |
|
109 * @since S60 v5.0 |
|
110 * @return The number of fields stored in for the current collection |
|
111 */ |
|
112 IMPORT_C TInt FieldCount() const; |
|
113 |
|
114 /** |
|
115 * Returns a pointer to a specific collection from the list of collections |
|
116 * |
|
117 * @since S60 v5.0 |
|
118 * @param aIndex The index of the required collection |
|
119 * @return The number of fields stored in for the current collection. |
|
120 * NULL if there are no collection object at the secified index |
|
121 */ |
|
122 IMPORT_C const CCollection* CollectionByIndex(TInt aIndex) const; |
|
123 |
|
124 /** |
|
125 * Returns a pointer to the field object at the given index within the field |
|
126 * list |
|
127 * |
|
128 * @since S60 v5.0 |
|
129 * @param aIndex The offset within the current field list |
|
130 * @return A pointer to the specified field object |
|
131 * NULL if there is no field object at the specified index |
|
132 */ |
|
133 IMPORT_C const CField* FieldByIndex(TInt aIndex) const; |
|
134 |
|
135 /** |
|
136 * Check if collection type is physical |
|
137 * |
|
138 * @since S60 v5.0 |
|
139 * @return true if physical |
|
140 */ |
|
141 IMPORT_C TBool IsPhysical() const; |
|
142 |
|
143 /** |
|
144 * Check if collection type is application |
|
145 * |
|
146 * @since S60 v5.0 |
|
147 * @return true if application |
|
148 */ |
|
149 IMPORT_C TBool IsApplication() const; |
|
150 |
|
151 /** |
|
152 * Check if collection type is logical |
|
153 * |
|
154 * @since S60 v5.0 |
|
155 * @return true if logical |
|
156 */ |
|
157 IMPORT_C TBool IsLogical() const; |
|
158 |
|
159 /** |
|
160 * Check if collection type is report |
|
161 * |
|
162 * @since S60 v5.0 |
|
163 * @return true if report |
|
164 */ |
|
165 IMPORT_C TBool IsReport() const; |
|
166 |
|
167 /** |
|
168 * Check if collection type is name array |
|
169 * |
|
170 * @since S60 v5.0 |
|
171 * @return true if named array |
|
172 */ |
|
173 IMPORT_C TBool IsNamedArray() const; |
|
174 |
|
175 /** |
|
176 * Check if collection type is usage switch |
|
177 * |
|
178 * @since S60 v5.0 |
|
179 * @return true if is usage switch |
|
180 */ |
|
181 IMPORT_C TBool IsUsageSwitch() const; |
|
182 |
|
183 /** |
|
184 * Check if collection type is usage modifier |
|
185 * |
|
186 * @since S60 v5.0 |
|
187 * @return true if usage modifier |
|
188 */ |
|
189 IMPORT_C TBool IsUsageModifier() const; |
|
190 |
|
191 public: |
|
192 |
|
193 /** |
|
194 * Set Collection type |
|
195 * |
|
196 * @since S60 v5.0 |
|
197 * @return None |
|
198 */ |
|
199 void SetType(TUint32 aType); |
|
200 |
|
201 /** |
|
202 * Set usage page |
|
203 * |
|
204 * @since S60 v5.0 |
|
205 * @return None |
|
206 */ |
|
207 void SetUsagePage(TInt aUsagePage); |
|
208 |
|
209 /** |
|
210 * Set usage |
|
211 * |
|
212 * @since S60 v5.0 |
|
213 * @return None |
|
214 */ |
|
215 void SetUsage(TInt aUsage); |
|
216 |
|
217 /** |
|
218 * Called when a new collection object has been encountered in |
|
219 * the report descriptor. This creates a new CCollection object |
|
220 * and adds it to the current list |
|
221 * |
|
222 * @since S60 v5.0 |
|
223 * @return None |
|
224 */ |
|
225 CCollection* AddCollectionL(); |
|
226 |
|
227 /** |
|
228 * Called when a new field object has been encountered in the |
|
229 * report descriptor. This creates a new field object and adds it |
|
230 * the the current list |
|
231 * |
|
232 * @since S60 v5.0 |
|
233 * @return A pointer to the new field object |
|
234 */ |
|
235 CField* AddFieldL(); |
|
236 |
|
237 protected: |
|
238 |
|
239 CCollection(); |
|
240 void ConstructL(); |
|
241 |
|
242 private: |
|
243 |
|
244 /** |
|
245 * Collection type |
|
246 */ |
|
247 TUint32 iType; |
|
248 |
|
249 /** |
|
250 * Usage page |
|
251 */ |
|
252 TInt iUsagePage; |
|
253 |
|
254 /** |
|
255 * Usage |
|
256 */ |
|
257 TInt iUsage; |
|
258 |
|
259 /** |
|
260 * List of collections for the report descriptor |
|
261 */ |
|
262 RPointerArray<CCollection> iCollections; |
|
263 |
|
264 /** |
|
265 * List of fields in the current collection |
|
266 */ |
|
267 RPointerArray<CField> iFields; |
|
268 |
|
269 }; |
|
270 |
|
271 #endif // C_COLLECTION_H |
|
272 |
|