1/*
2 * Copyright 2009-2011, Michael Lotz, mmlr@mlotz.ch.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef HID_COLLECTION_H
6#define HID_COLLECTION_H
7
8#include "HIDParser.h"
9
10class HIDReport;
11class HIDReportItem;
12
13class HIDCollection {
14public:
15								HIDCollection(HIDCollection *parent,
16									uint8 type, local_item_state &localState);
17								~HIDCollection();
18
19		uint8					Type() { return fType; };
20
21		uint16					UsagePage();
22		uint16					UsageID();
23
24		HIDCollection *			Parent() { return fParent; };
25
26		status_t				AddChild(HIDCollection *child);
27		uint32					CountChildren() { return fChildCount; };
28		HIDCollection *			ChildAt(uint32 index);
29
30		uint32					CountChildrenFlat(uint8 type);
31		HIDCollection *			ChildAtFlat(uint8 type, uint32 index);
32
33		void					AddItem(HIDReportItem *item);
34		uint32					CountItems() { return fItemCount; };
35		HIDReportItem *			ItemAt(uint32 index);
36
37		uint32					CountItemsFlat();
38		HIDReportItem *			ItemAtFlat(uint32 index);
39
40		void					BuildReportList(uint8 reportType,
41									HIDReport **reportList,
42									uint32 &reportCount);
43
44		void					PrintToStream(uint32 indentLevel = 0);
45
46private:
47		HIDCollection *			_ChildAtFlat(uint8 type, uint32 &index);
48		HIDReportItem *			_ItemAtFlat(uint32 &index);
49
50		HIDCollection *			fParent;
51
52		uint8					fType;
53		uint32					fUsage;
54		uint8					fStringID;
55		uint8					fPhysicalID;
56
57		uint32					fChildCount;
58		HIDCollection **		fChildren;
59
60		uint32					fItemCount;
61		uint32					fItemsAllocated;
62		HIDReportItem **		fItems;
63};
64
65#endif // HID_COLLECTION_H
66