1/*
2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Pieter Panman
7 */
8#ifndef DEVICE_H
9#define DEVICE_H
10
11
12#include <map>
13#include <vector>
14
15#include <String.h>
16#include <StringItem.h>
17
18extern "C" {
19#include "dm_wrapper.h"
20}
21
22
23typedef enum {
24	BUS_ISA = 1,
25	BUS_PCI,
26	BUS_SCSI,
27	BUS_ACPI,
28	BUS_USB,
29	BUS_NONE
30} BusType;
31
32
33struct Attribute {
34			Attribute(BString name, BString value)
35				{ fName = name; fValue = value; }
36	BString	fName;
37	BString	fValue;
38};
39
40
41typedef std::map<BString, BString>::const_iterator AttributeMapIterator;
42typedef std::map<BString, BString> AttributeMap;
43typedef std::pair<BString, BString> AttributePair;
44typedef std::vector<Attribute> Attributes;
45
46
47typedef enum {
48	CAT_NONE,		// 0x00
49	CAT_MASS,		// 0x01
50	CAT_NETWORK,	// 0x02
51	CAT_DISPLAY,	// 0x03
52	CAT_MULTIMEDIA,	// 0x04
53	CAT_MEMORY,		// 0x05
54	CAT_BUS,		// 0x06
55	CAT_COMM,		// 0x07
56	CAT_GENERIC,	// 0x08
57	CAT_INPUT,		// 0x09
58	CAT_DOCK,		// 0x0A
59	CAT_CPU,		// 0x0B
60	CAT_SERIAL,		// 0x0C
61	CAT_WIRELESS,	// 0x0D
62	CAT_INTEL,		// 0x0E
63	CAT_SATELLITE,	// 0x0F
64	CAT_CRYPTO,		// 0x10
65	CAT_SIGNAL,		// 0x11
66	CAT_COMPUTER,	// 0x12
67	CAT_ACPI		// 0x13
68} Category;
69
70
71extern const char* kCategoryString[];
72extern const int kCategoryStringLength;
73
74
75class Device : public BStringItem {
76public:
77							Device(Device* physicalParent,
78								BusType busType = BUS_NONE,
79								Category category = CAT_NONE,
80								const BString& name = "unknown",
81								const BString& manufacturer = "unknown",
82								const BString& driverUsed = "unknown",
83								const BString& devPathsPublished = "unknown");
84	virtual					~Device();
85
86	virtual BString			GetName();
87	virtual BString			GetManufacturer();
88	virtual BString			GetDriverUsed();
89	virtual BString			GetDevPathsPublished();
90	virtual Category		GetCategory() const
91								{ return fCategory; }
92	virtual Device*			GetPhysicalParent() const
93								{ return fPhysicalParent; }
94	virtual BusType			GetBusType() const
95								{ return fBusType; }
96
97	virtual Attributes		GetAllAttributes();
98	virtual BString			GetAllStrings();
99
100	virtual Attribute		GetAttribute(const BString& name)
101								{ return Attribute(name.String(),
102									 fAttributeMap[name]); }
103
104	virtual void 			SetAttribute(const BString& name,
105								const BString& value);
106
107	virtual void			InitFromAttributes() { return; }
108
109protected:
110			AttributeMap	fAttributeMap;
111			BusType			fBusType;
112			Category		fCategory;
113			Device*			fPhysicalParent;
114};
115
116#endif /* DEVICE_H */
117
118