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 18 extern "C" { 19 #include "dm_wrapper.h" 20 } 21 22 23 typedef enum { 24 BUS_ISA = 1, 25 BUS_PCI, 26 BUS_SCSI, 27 BUS_ACPI, 28 BUS_NONE 29 } BusType; 30 31 32 struct Attribute { 33 Attribute(BString name, BString value) 34 { fName = name; fValue = value; } 35 BString fName; 36 BString fValue; 37 }; 38 39 40 typedef std::map<BString, BString>::const_iterator AttributeMapIterator; 41 typedef std::map<BString, BString> AttributeMap; 42 typedef std::pair<BString, BString> AttributePair; 43 typedef std::vector<Attribute> Attributes; 44 45 46 typedef 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 70 extern const char* kCategoryString[]; 71 extern const int kCategoryStringLength; 72 73 74 class Device : public BStringItem { 75 public: 76 Device(Device* physicalParent, 77 BusType busType = BUS_NONE, 78 Category category = CAT_NONE, 79 const BString& name = "unknown", 80 const BString& manufacturer = "unknown", 81 const BString& driverUsed = "unknown", 82 const BString& devPathsPublished = "unknown"); 83 virtual ~Device(); 84 85 virtual BString GetName(); 86 virtual BString GetManufacturer(); 87 virtual BString GetDriverUsed(); 88 virtual BString GetDevPathsPublished(); 89 virtual Category GetCategory() const 90 { return fCategory; } 91 virtual Device* GetPhysicalParent() const 92 { return fPhysicalParent; } 93 virtual BusType GetBusType() const 94 { return fBusType; } 95 96 virtual Attributes GetBasicAttributes(); 97 virtual Attributes GetBusAttributes(); 98 virtual Attributes GetAllAttributes(); 99 100 virtual BString GetBasicStrings(); 101 virtual BString GetBusStrings(); 102 virtual BString GetAllStrings(); 103 104 virtual BString GetBusTabName(); 105 106 virtual Attribute GetAttribute(const BString& name) 107 { return Attribute(name.String(), 108 fAttributeMap[name]); } 109 110 virtual void SetAttribute(const BString& name, 111 const BString& value); 112 113 virtual void InitFromAttributes() { return; } 114 115 protected: 116 AttributeMap fAttributeMap; 117 BusType fBusType; 118 Category fCategory; 119 Device* fPhysicalParent; 120 }; 121 122 #endif /* DEVICE_H */ 123 124