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_NONE
29} BusType;
30
31
32struct Attribute {
33			Attribute(BString name, BString value)
34				{ fName = name; fValue = value; }
35	BString	fName;
36	BString	fValue;
37};
38
39
40typedef std::map<BString, BString>::const_iterator AttributeMapIterator;
41typedef std::map<BString, BString> AttributeMap;
42typedef std::pair<BString, BString> AttributePair;
43typedef std::vector<Attribute> Attributes;
44
45
46typedef enum {
47	CAT_NONE,		// 0x00
48	CAT_MASS,		// 0x01
49	CAT_NETWORK,	// 0x02
50	CAT_DISPLAY,	// 0x03
51	CAT_MULTIMEDIA,	// 0x04
52	CAT_MEMORY,		// 0x05
53	CAT_BUS,		// 0x06
54	CAT_COMM,		// 0x07
55	CAT_GENERIC,	// 0x08
56	CAT_INPUT,		// 0x09
57	CAT_DOCK,		// 0x0A
58	CAT_CPU,		// 0x0B
59	CAT_SERIAL,		// 0x0C
60	CAT_WIRELESS,	// 0x0D
61	CAT_INTEL,		// 0x0E
62	CAT_SATELLITE,	// 0x0F
63	CAT_CRYPTO,		// 0x10
64	CAT_SIGNAL,		// 0x11
65	CAT_COMPUTER,	// 0x12
66	CAT_ACPI		// 0x13
67} Category;
68
69
70extern const char* kCategoryString[];
71
72
73class Device : public BStringItem {
74public:
75							Device(Device* physicalParent,
76								BusType busType = BUS_NONE,
77								Category category = CAT_NONE,
78								const BString& name = "unknown",
79								const BString& manufacturer = "unknown",
80								const BString& driverUsed = "unknown",
81								const BString& devPathsPublished = "unknown");
82	virtual					~Device();
83
84	virtual BString			GetName();
85	virtual BString			GetManufacturer();
86	virtual BString			GetDriverUsed();
87	virtual BString			GetDevPathsPublished();
88	virtual Category		GetCategory() const
89								{ return fCategory; }
90	virtual Device*			GetPhysicalParent() const
91								{ return fPhysicalParent; }
92	virtual BusType			GetBusType() const
93								{ return fBusType; }
94
95	virtual Attributes		GetBasicAttributes();
96	virtual Attributes		GetBusAttributes();
97	virtual Attributes		GetAllAttributes();
98
99	virtual BString			GetBasicStrings();
100	virtual BString			GetBusStrings();
101	virtual BString			GetAllStrings();
102
103	virtual BString			GetBusTabName();
104
105	virtual Attribute		GetAttribute(const BString& name)
106								{ return Attribute(name.String(),
107									 fAttributeMap[name]); }
108
109	virtual void 			SetAttribute(const BString& name,
110								const BString& value);
111
112	virtual void			InitFromAttributes() { return; }
113
114protected:
115			AttributeMap	fAttributeMap;
116			BusType			fBusType;
117			Category		fCategory;
118			Device*			fPhysicalParent;
119};
120
121#endif /* DEVICE_H */
122
123