| 1 | #include "DevicePkgRef.h" |
|---|
| 2 | #include "HWDeviceRegistration.h" |
|---|
| 3 | #include "DevicePkg.h" |
|---|
| 4 | |
|---|
| 5 | #include <iostream> |
|---|
| 6 | |
|---|
| 7 | // test functions |
|---|
| 8 | void testLocalFile(); |
|---|
| 9 | void testDeviceClass(); |
|---|
| 10 | void testDevicePkgRef(); |
|---|
| 11 | void testPropertyFile(); |
|---|
| 12 | void testHWDeviceRegistration(); |
|---|
| 13 | void testDevicePkg(); |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | int main() |
|---|
| 17 | { |
|---|
| 18 | std::cout << std::endl; |
|---|
| 19 | std::cout << "running test app..." << std::endl; |
|---|
| 20 | |
|---|
| 21 | //testDeviceClass(); |
|---|
| 22 | //testDevicePkgRef(); |
|---|
| 23 | //testPropertyFile(); |
|---|
| 24 | //testHWDeviceRegistration(); |
|---|
| 25 | testDevicePkg(); |
|---|
| 26 | |
|---|
| 27 | std::cout << std::endl; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | void testDevicePkg() |
|---|
| 31 | { |
|---|
| 32 | std::cout << "testDevicePkg()" << std::endl; |
|---|
| 33 | |
|---|
| 34 | char *root = "xml/devicePkg.xml"; |
|---|
| 35 | TiXmlDocument xmlDoc(root); // set up path to XML through char string |
|---|
| 36 | |
|---|
| 37 | if (xmlDoc.LoadFile()) |
|---|
| 38 | { |
|---|
| 39 | TiXmlHandle doc(&xmlDoc); // get handle to XML file |
|---|
| 40 | TiXmlElement *devpkg = doc.FirstChild("devicepkg").Element(); |
|---|
| 41 | |
|---|
| 42 | DevicePkg parse(devpkg); |
|---|
| 43 | |
|---|
| 44 | // print xml tags ... |
|---|
| 45 | std::cout << "******************************" << std::endl; |
|---|
| 46 | std::cout << "DevicePkg: " << std::endl; |
|---|
| 47 | std::cout << "<devicepkg id=" << parse.getDevPkgID() << " version=" << parse.getDevPkgVersion() << " name=" << parse.getDevPkgName() << ">" << std::endl; |
|---|
| 48 | std::cout << " <title>" << parse.getDevPkgTitle() << "</title>" << std::endl; |
|---|
| 49 | std::cout << " <author>" << parse.getDevPkgAuthor() << "</author>" << std::endl; |
|---|
| 50 | std::cout << " <description>" << parse.getDevPkgDescription() << "</description>" << std::endl; |
|---|
| 51 | std::cout << " <hwdeviceregistration id=" << parse.getHWDevRegID() << " version=" << parse.getHWDevRegVersion(); |
|---|
| 52 | std::cout << " name=" << parse.getHWDevRegName() << ">" << std::endl; |
|---|
| 53 | std::cout << " <propertyfile type=" << parse.getPropFileType() << ">" << std::endl; |
|---|
| 54 | std::cout << " <localfile name=" << parse.getPropFileLocalFile() << "/>" << std::endl; |
|---|
| 55 | std::cout << " </propertyfile>" << std::endl; |
|---|
| 56 | std::cout << " <description>" << parse.getHWDevRegDescription() << "</description>" << std::endl; |
|---|
| 57 | std::cout << " <manufacturer>" << parse.getHWDevRegManufacturer() << "</manufacturer>" << std::endl; |
|---|
| 58 | std::cout << " <modelnumber>" << parse.getHWDevRegModelNumber() << "</modelnumber>" << std::endl; |
|---|
| 59 | std::cout << " <deviceclass>" << std::endl; |
|---|
| 60 | for (int i = 0; i < parse.getDeviceClass().size(); i++) |
|---|
| 61 | { |
|---|
| 62 | std::cout << " <class>" << parse.getDeviceClass()[i] << "</class>" << std::endl; |
|---|
| 63 | } |
|---|
| 64 | std::cout << " </deviceclass>" << std::endl; |
|---|
| 65 | |
|---|
| 66 | for (int i = 0; i < parse.getChildHWDevice().size(); i++) |
|---|
| 67 | { |
|---|
| 68 | std::cout << " <childhwdevice>" << std::endl; |
|---|
| 69 | // std::cout << " <hwdeviceregistration id=" << parse.getChildHWDevice()[i]->getHWDeviceRegistration().getHWDevRegID() << std::endl; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | std::cout << "</devicepkg>" << std::endl; |
|---|
| 76 | } |
|---|
| 77 | else |
|---|
| 78 | { |
|---|
| 79 | std::cout << "can't load file: " << root << std::endl; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | void testPropertyFile() |
|---|
| 86 | { |
|---|
| 87 | std::cout << "testPropertyFile()" << std::endl; |
|---|
| 88 | |
|---|
| 89 | char *root = "xml/propertyFile.xml"; |
|---|
| 90 | TiXmlDocument xmlDoc(root); // set up path to XML through char string |
|---|
| 91 | |
|---|
| 92 | if (xmlDoc.LoadFile()) |
|---|
| 93 | { |
|---|
| 94 | TiXmlHandle doc(&xmlDoc); // get handle to XML file |
|---|
| 95 | TiXmlElement *propFile = doc.FirstChild("propertyfile").Element(); |
|---|
| 96 | |
|---|
| 97 | PropertyFile parse(propFile); |
|---|
| 98 | } |
|---|
| 99 | else |
|---|
| 100 | { |
|---|
| 101 | std::cout << "can't load the file " << root << std::endl; |
|---|
| 102 | } |
|---|
| 103 | std::cout << std::endl; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | void testHWDeviceRegistration() |
|---|
| 108 | { |
|---|
| 109 | std::cout << "testHWDeviceRegistration()" << std::endl; |
|---|
| 110 | |
|---|
| 111 | char *root = "xml/hwDeviceRegistration.xml"; |
|---|
| 112 | TiXmlDocument xmlDoc(root); // set up path to XML through char string |
|---|
| 113 | |
|---|
| 114 | if (xmlDoc.LoadFile()) |
|---|
| 115 | { |
|---|
| 116 | TiXmlHandle doc(&xmlDoc); // get handle to XML file |
|---|
| 117 | TiXmlElement *devReg = doc.FirstChild("hwdeviceregistration").Element(); |
|---|
| 118 | |
|---|
| 119 | HWDeviceRegistration parse(devReg); |
|---|
| 120 | |
|---|
| 121 | std::cout << std::endl << std::endl; |
|---|
| 122 | |
|---|
| 123 | } |
|---|
| 124 | else |
|---|
| 125 | { |
|---|
| 126 | std::cout << "you botched it, can't load " << root << std::endl; |
|---|
| 127 | } |
|---|
| 128 | std::cout << std::endl; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | void testDevicePkgRef() |
|---|
| 132 | { |
|---|
| 133 | std::cout << "testDevicePkgRef()" << std::endl; |
|---|
| 134 | |
|---|
| 135 | char *root = "xml/devicePkgRef.xml"; |
|---|
| 136 | TiXmlDocument xmlDoc(root); // set up path to XML through char string |
|---|
| 137 | |
|---|
| 138 | if (xmlDoc.LoadFile()) |
|---|
| 139 | { |
|---|
| 140 | TiXmlHandle doc(&xmlDoc); // get handle to XML file |
|---|
| 141 | TiXmlElement *devPkgRef = doc.FirstChild("devicepkgref").Element(); |
|---|
| 142 | |
|---|
| 143 | DevicePkgRef parse(devPkgRef); |
|---|
| 144 | } |
|---|
| 145 | else |
|---|
| 146 | { |
|---|
| 147 | std::cout << "you botched it, couldn't load " << root << std::endl; |
|---|
| 148 | } |
|---|
| 149 | std::cout << std::endl; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | void testDeviceClass() |
|---|
| 153 | { |
|---|
| 154 | std::cout << "testDeviceClass()" << std::endl; |
|---|
| 155 | char *root = "xml/deviceClass.xml"; |
|---|
| 156 | TiXmlDocument xmlDoc(root); // set up path to XML through character string |
|---|
| 157 | |
|---|
| 158 | if (xmlDoc.LoadFile()) |
|---|
| 159 | { |
|---|
| 160 | TiXmlHandle doc(&xmlDoc); // get handle to XML file |
|---|
| 161 | TiXmlElement *devClass = doc.FirstChild("deviceclass").Element(); |
|---|
| 162 | DeviceClass parse(devClass); |
|---|
| 163 | |
|---|
| 164 | std::cout << "*************************" << std::endl; |
|---|
| 165 | std::cout << "DeviceClass: " << std::endl; |
|---|
| 166 | std::cout << "Classes: " << std::endl; |
|---|
| 167 | |
|---|
| 168 | int size = parse.getDeviceClass().size(); |
|---|
| 169 | for (int i = 0; i < size; i++) |
|---|
| 170 | { |
|---|
| 171 | std::cout << parse.getDeviceClass()[i] << ", "; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | std::cout << std::endl; |
|---|
| 175 | std::cout << "*************************" << std::endl; |
|---|
| 176 | } |
|---|
| 177 | else |
|---|
| 178 | { |
|---|
| 179 | std::cout << "you botched it, couldn't load " << root << std::endl; |
|---|
| 180 | } |
|---|
| 181 | std::cout << std::endl; |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | |
|---|