| 1 | #include "HWDeviceRegistration.h" |
|---|
| 2 | #include "PropertyFile.h" |
|---|
| 3 | #include "DeviceClass.h" |
|---|
| 4 | |
|---|
| 5 | #include <iostream> |
|---|
| 6 | |
|---|
| 7 | #include "include/tinyxml.h" |
|---|
| 8 | |
|---|
| 9 | HWDeviceRegistration::HWDeviceRegistration(TiXmlElement *elem):PropertyFile(elem->FirstChildElement("propertyfile")), |
|---|
| 10 | DeviceClass(elem->FirstChildElement("deviceclass")) |
|---|
| 11 | { |
|---|
| 12 | parseElement(elem); // parse tags in hwdeviceregistration, with exception of propertyfile, deviceclass, childhwdevice |
|---|
| 13 | constructChildHWDevice(elem->FirstChildElement("childhwdevice")); // cannot call constructor on ChildHWDevice, use this function to do it |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | HWDeviceRegistration::~HWDeviceRegistration() |
|---|
| 17 | { |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | void HWDeviceRegistration::constructChildHWDevice(TiXmlElement *elem) |
|---|
| 21 | { |
|---|
| 22 | // parse childhwdevice tag(s) |
|---|
| 23 | for (; elem; elem=elem->NextSiblingElement("childhwdevice")) |
|---|
| 24 | { |
|---|
| 25 | // create child device object |
|---|
| 26 | ChildHWDevice *cDevice; |
|---|
| 27 | cDevice = new ChildHWDevice(elem); |
|---|
| 28 | |
|---|
| 29 | // push new child device onto vector |
|---|
| 30 | childHWDevices.push_back(cDevice); |
|---|
| 31 | } |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | // parse attributes within hwdeviceregistration tag |
|---|
| 35 | void HWDeviceRegistration::parseElement(TiXmlElement *elem) |
|---|
| 36 | { |
|---|
| 37 | std::cout << "DEBUG: parsing hw device registration tag..." << std::endl; |
|---|
| 38 | |
|---|
| 39 | // pull info from hwdeviceregistration tag |
|---|
| 40 | id = elem->Attribute("id"); |
|---|
| 41 | version = elem->Attribute("version"); |
|---|
| 42 | name = elem->Attribute("name"); |
|---|
| 43 | |
|---|
| 44 | // description, manufacturer, modelnumber tags |
|---|
| 45 | TiXmlElement *descrip = elem->FirstChildElement("description"); |
|---|
| 46 | description = descrip->GetText(); |
|---|
| 47 | |
|---|
| 48 | TiXmlElement *manufac = elem->FirstChildElement("manufacturer"); |
|---|
| 49 | manufacturer = manufac->GetText(); |
|---|
| 50 | |
|---|
| 51 | TiXmlElement *modNum = elem->FirstChildElement("modelnumber"); |
|---|
| 52 | modelnumber = modNum->GetText(); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | ChildHWDevice::ChildHWDevice(TiXmlElement *elem):DevicePkgRef(elem->FirstChildElement("devicepkgref")) |
|---|
| 56 | { |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | ChildHWDevice::~ChildHWDevice() |
|---|
| 60 | { |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | std::vector <ChildHWDevice*> HWDeviceRegistration::getChildHWDevice() |
|---|
| 64 | { |
|---|
| 65 | return childHWDevices; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | std::string HWDeviceRegistration::getHWDevRegID() |
|---|
| 69 | { |
|---|
| 70 | return id; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | std::string HWDeviceRegistration::getHWDevRegVersion() |
|---|
| 74 | { |
|---|
| 75 | return version; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | std::string HWDeviceRegistration::getHWDevRegName() |
|---|
| 79 | { |
|---|
| 80 | return name; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | std::string HWDeviceRegistration::getHWDevRegDescription() |
|---|
| 84 | { |
|---|
| 85 | return description; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | std::string HWDeviceRegistration::getHWDevRegManufacturer() |
|---|
| 89 | { |
|---|
| 90 | return manufacturer; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | std::string HWDeviceRegistration::getHWDevRegModelNumber() |
|---|
| 94 | { |
|---|
| 95 | return modelnumber; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|