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#include "util/Vector.h"
10
11
12class HIDReport;
13class HIDReportItem;
14
15class HIDCollection {
16public:
17								HIDCollection(HIDCollection *parent,
18									uint8 type, local_item_state &localState);
19								~HIDCollection();
20
21		uint8					Type() { return fType; };
22
23		uint16					UsagePage();
24		uint16					UsageID();
25
26		HIDCollection *			Parent() { return fParent; };
27
28		status_t				AddChild(HIDCollection *child);
29		uint32					CountChildren() { return fChildren.Count(); };
30		HIDCollection *			ChildAt(uint32 index);
31
32		uint32					CountChildrenFlat(uint8 type);
33		HIDCollection *			ChildAtFlat(uint8 type, uint32 index);
34
35		void					AddItem(HIDReportItem *item);
36		uint32					CountItems() { return fItems.Count(); };
37		HIDReportItem *			ItemAt(uint32 index);
38
39		uint32					CountItemsFlat();
40		HIDReportItem *			ItemAtFlat(uint32 index);
41
42		void					BuildReportList(uint8 reportType,
43									HIDReport **reportList,
44									uint32 &reportCount);
45
46		void					PrintToStream(uint32 indentLevel = 0);
47
48private:
49		HIDCollection *			_ChildAtFlat(uint8 type, uint32 &index);
50		HIDReportItem *			_ItemAtFlat(uint32 &index);
51
52		HIDCollection *			fParent;
53
54		uint8					fType;
55		uint32					fUsage;
56		uint8					fStringID;
57		uint8					fPhysicalID;
58		Vector<HIDCollection *>	fChildren;
59		Vector<HIDReportItem *>	fItems;
60
61};
62
63#endif // HID_COLLECTION_H
64