1 /* |
|
2 * Copyright (c) 2004-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: Hid field implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <e32des8.h> |
|
22 #include <e32svr.h> |
|
23 |
|
24 #include "hidreportroot.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // NewL() |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CField* CField::NewL() |
|
33 { |
|
34 CField* self = NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // NewLC() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CField* CField::NewLC() |
|
44 { |
|
45 // Two-phase construction isn't necessary at present: |
|
46 CField* self = new (ELeave) CField; |
|
47 CleanupStack::PushL(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CField() |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CField::CField() |
|
56 { |
|
57 // nothing else to do |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Destructor |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CField::~CField() |
|
65 { |
|
66 iUsageList.Close(); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // UsagePage() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C TInt CField::UsagePage() const |
|
74 { |
|
75 return iUsagePage; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // ReportId() |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C TInt CField::ReportId() const |
|
83 { |
|
84 return iReportId; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // Offset() |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C TInt CField::Offset() const |
|
92 { |
|
93 return (iReportId == 0) ? iPos : (iPos+KSizeOfByte); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Size() |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C TInt CField::Size() const |
|
101 { |
|
102 return iSize; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Count() |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C TInt CField::Count() const |
|
110 { |
|
111 return iCount; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // LogicalMin() |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C TInt CField::LogicalMin() const |
|
119 { |
|
120 return iLogicalMin; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // LogicalMax() |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C TInt CField::LogicalMax() const |
|
128 { |
|
129 return iLogicalMax; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // UsageMin() |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 EXPORT_C TInt CField::UsageMin() const |
|
137 { |
|
138 return iUsageMin; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // UsageMax() |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 EXPORT_C TInt CField::UsageMax() const |
|
146 { |
|
147 return iUsageMax; |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // PhysicalMin() |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C TInt CField::PhysicalMin() const |
|
155 { |
|
156 return iPhysicalMin; |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // PhysicalMax() |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C TInt CField::PhysicalMax() const |
|
164 { |
|
165 return iPhysicalMax; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // Unit() |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C TInt CField::Unit() const |
|
173 { |
|
174 return iUnit; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // UnitExponent() |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TInt CField::UnitExponent() const |
|
182 { |
|
183 return iUnitExponent; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // DesignatorIndex() |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 EXPORT_C TInt CField::DesignatorIndex() const |
|
191 { |
|
192 return iDesignatorIndex; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // DesignatorMin() |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C TInt CField::DesignatorMin() const |
|
200 { |
|
201 return iDesignatorMin; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // DesignatorMax() |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 EXPORT_C TInt CField::DesignatorMax() const |
|
209 { |
|
210 return iDesignatorMax; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // StringMin() |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 EXPORT_C TInt CField::StringMin() const |
|
218 { |
|
219 return iStringMin; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // StringMax() |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 EXPORT_C TInt CField::StringMax() const |
|
227 { |
|
228 return iStringMax; |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // StringIndex() |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 EXPORT_C TInt CField::StringIndex() const |
|
236 { |
|
237 return iStringIndex; |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // UsageArray() |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 EXPORT_C TArray<TInt> CField::UsageArray() const |
|
245 { |
|
246 return iUsageList.Array(); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // HasUsage() |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 EXPORT_C TBool CField::HasUsage(const TInt aUsage) const |
|
254 { |
|
255 return iUsageList.Find(aUsage) != KErrNotFound; |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // AddUsageL |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C void CField::AddUsageL(const TInt aUsage) |
|
263 { |
|
264 User::LeaveIfError(iUsageList.Append(aUsage)); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // ClearUsageList() |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 EXPORT_C void CField::ClearUsageList() |
|
272 { |
|
273 iUsageList.Reset(); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // LastUsage() |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 EXPORT_C TInt CField::LastUsage() const |
|
281 { |
|
282 TInt usage = 0; |
|
283 if (iUsageList.Count() > 0) |
|
284 { |
|
285 usage = iUsageList[iUsageList.Count()-1]; |
|
286 } |
|
287 return usage; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // Attributes() |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 EXPORT_C TUint32 CField::Attributes() const |
|
295 { |
|
296 return iAttributes; |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // Type() |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 EXPORT_C CField::TType CField::Type() const |
|
304 { |
|
305 return iType; |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // IsVariable() |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 EXPORT_C TBool CField::IsVariable() const |
|
313 { |
|
314 return (( iAttributes & KFieldAttributeVariable ) != 0); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // IsArray() |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 EXPORT_C TBool CField::IsArray() const |
|
322 { |
|
323 return ( ( iAttributes & KFieldAttributeVariable ) == 0); |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // IsConstant() |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C TBool CField::IsConstant() const |
|
331 { |
|
332 return (( iAttributes & KFieldAttributeConstant ) != 0 ); |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // IsData() |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 EXPORT_C TBool CField::IsData() const |
|
340 { |
|
341 // Field atribute first bit present if data is constat or is it data. |
|
342 // If first bit is zero field attibute data is set. |
|
343 return ( ( iAttributes & KFieldAttributeConstant ) == 0 ); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // SetType() |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 EXPORT_C void CField::SetType(const TType& aType) |
|
351 { |
|
352 iType = aType; |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // SetUsagePage() |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 EXPORT_C void CField::SetUsagePage(const TInt aUsagePage) |
|
360 { |
|
361 iUsagePage = aUsagePage; |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // Destructor() |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 EXPORT_C void CField::SetReportId(const TInt aId) |
|
369 { |
|
370 iReportId = aId; |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // SetOffset() |
|
375 // --------------------------------------------------------------------------- |
|
376 // |
|
377 EXPORT_C void CField::SetOffset(const TInt aOffset) |
|
378 { |
|
379 iPos = aOffset; |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // SetSize() |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 EXPORT_C void CField::SetSize(const TInt aSize) |
|
387 { |
|
388 iSize = aSize; |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // SetCount() |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 EXPORT_C void CField::SetCount(const TInt aCount) |
|
396 { |
|
397 iCount = aCount; |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------------------------- |
|
401 // SetLogicalMin() |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void CField::SetLogicalMin(const TInt aMin) |
|
405 { |
|
406 iLogicalMin = aMin; |
|
407 } |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // SetLogicalMax() |
|
411 // --------------------------------------------------------------------------- |
|
412 // |
|
413 EXPORT_C void CField::SetLogicalMax(const TInt aMax) |
|
414 { |
|
415 iLogicalMax = aMax; |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // SetUsageMin() |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 EXPORT_C void CField::SetUsageMin(const TInt aMin) |
|
423 { |
|
424 iUsageMin = aMin; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // SetUsageMax() |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C void CField::SetUsageMax(const TInt aMax) |
|
432 { |
|
433 iUsageMax = aMax; |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // SetAttributes() |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 EXPORT_C void CField::SetAttributes(const TUint32 aAttributes) |
|
441 { |
|
442 iAttributes = aAttributes; |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // SetPhysicalMin() |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 EXPORT_C void CField::SetPhysicalMin(TInt aValue) |
|
450 { |
|
451 iPhysicalMin = aValue; |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // SetPhysicalMax() |
|
456 // --------------------------------------------------------------------------- |
|
457 // |
|
458 EXPORT_C void CField::SetPhysicalMax(TInt aValue) |
|
459 { |
|
460 iPhysicalMax = aValue; |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // SetUnit() |
|
465 // --------------------------------------------------------------------------- |
|
466 // |
|
467 EXPORT_C void CField::SetUnit(TInt aValue) |
|
468 { |
|
469 iUnit = aValue; |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // SetUnitExponent() |
|
474 // --------------------------------------------------------------------------- |
|
475 // |
|
476 EXPORT_C void CField::SetUnitExponent(TInt aValue) |
|
477 { |
|
478 iUnitExponent = aValue; |
|
479 } |
|
480 |
|
481 // --------------------------------------------------------------------------- |
|
482 // SetDesignatorIndex() |
|
483 // --------------------------------------------------------------------------- |
|
484 // |
|
485 EXPORT_C void CField::SetDesignatorIndex(TInt aValue) |
|
486 { |
|
487 iDesignatorIndex = aValue; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // SetDesignatorMin() |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C void CField::SetDesignatorMin(TInt aValue) |
|
495 { |
|
496 iDesignatorMin = aValue; |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // SetDesignatorMax() |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 EXPORT_C void CField::SetDesignatorMax(TInt aValue) |
|
504 { |
|
505 iDesignatorMax = aValue; |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // SetStringMin() |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 EXPORT_C void CField::SetStringMin(TInt aValue) |
|
513 { |
|
514 iStringMin = aValue; |
|
515 } |
|
516 |
|
517 // --------------------------------------------------------------------------- |
|
518 // SetStringMax() |
|
519 // --------------------------------------------------------------------------- |
|
520 // |
|
521 EXPORT_C void CField::SetStringMax(TInt aValue) |
|
522 { |
|
523 iStringMax = aValue; |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // SetStringIndex() |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 EXPORT_C void CField::SetStringIndex(TInt aValue) |
|
531 { |
|
532 iStringIndex = aValue; |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // SetLogicalRange() |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 EXPORT_C void CField::SetLogicalRange(TInt aMin, TInt aMax) |
|
540 { |
|
541 iLogicalMin = aMin; |
|
542 iLogicalMax = aMax; |
|
543 } |
|
544 |
|
545 // --------------------------------------------------------------------------- |
|
546 // SetUsageRange() |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 EXPORT_C void CField::SetUsageRange(TInt aMin, TInt aMax) |
|
550 { |
|
551 iUsageMin = aMin; |
|
552 iUsageMax = aMax; |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // SetPhysicalRange |
|
557 // --------------------------------------------------------------------------- |
|
558 // |
|
559 EXPORT_C void CField::SetPhysicalRange(TInt aMin, TInt aMax) |
|
560 { |
|
561 iPhysicalMin = aMin; |
|
562 iPhysicalMax = aMax; |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // SetStringRange() |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 EXPORT_C void CField::SetStringRange(TInt aMin, TInt aMax) |
|
570 { |
|
571 iStringMin = aMin; |
|
572 iStringMax = aMax; |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // SetDesignatorRange() |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 EXPORT_C void CField::SetDesignatorRange(TInt aMin, TInt aMax) |
|
580 { |
|
581 iDesignatorMin = aMin; |
|
582 iDesignatorMax = aMax; |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------------------------- |
|
586 // IsInput() |
|
587 // --------------------------------------------------------------------------- |
|
588 // |
|
589 EXPORT_C TBool CField::IsInput() const |
|
590 { |
|
591 return iType == EInput; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // IsOutput() |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 EXPORT_C TBool CField::IsOutput() const |
|
599 { |
|
600 return iType == EOutput; |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // IsFeature() |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 EXPORT_C TBool CField::IsFeature() const |
|
608 { |
|
609 return iType == EFeature; |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------------------------- |
|
613 // UsageCount() |
|
614 // --------------------------------------------------------------------------- |
|
615 // |
|
616 EXPORT_C TInt CField::UsageCount() const |
|
617 { |
|
618 return iUsageList.Count(); |
|
619 } |
|
620 |
|
621 // --------------------------------------------------------------------------- |
|
622 // Usage() |
|
623 // --------------------------------------------------------------------------- |
|
624 // |
|
625 EXPORT_C TInt CField::Usage(TInt aIndex) const |
|
626 { |
|
627 return iUsageList[aIndex]; |
|
628 } |
|
629 |
|
630 // --------------------------------------------------------------------------- |
|
631 // IsInReport() |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 EXPORT_C TBool CField::IsInReport(TInt aReportId) const |
|
635 { |
|
636 return ( 0 == iReportId || aReportId == iReportId ); |
|
637 } |
|
638 |
|