/* * © Copyright 2014 – Urheberrechtshinweis * Alle Rechte vorbehalten / All Rights Reserved * * Programmcode ist urheberrechtlich geschuetzt. * Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner. * Keine Verwendung ohne explizite Genehmigung. * (vgl. § 106 ff UrhG / § 97 UrhG) */ #ifndef WIFIMODELFACTORYIMPL_H #define WIFIMODELFACTORYIMPL_H #include "WiFiModelFactory.h" #include "WiFiModelLogDist.h" #include "WiFiModelLogDistCeiling.h" #include "WiFiModelPerFloor.h" #include "WiFiModelPerBBox.h" WiFiModel* WiFiModelFactory::loadXML(const std::string& file) { XMLDoc doc; XMLserialize::assertOK(doc.LoadFile(file.c_str()), doc, "error while loading file"); XMLElem* root = doc.FirstChildElement("root"); return readFromXML(&doc, root); } WiFiModel* WiFiModelFactory::readFromXML(XMLDoc* doc, XMLElem* src) { // each model attaches its "type" during serialization const std::string type = src->Attribute("type"); WiFiModel* mdl = nullptr; // create an instance for the model if (type == "WiFiModelLogDist") {Log::add(name, "loading WiFiModelLogDist"); mdl = new WiFiModelLogDist();} else if (type == "WiFiModelLogDistCeiling") {Log::add(name, "loading WiFiModelLogDistCeiling"); mdl = new WiFiModelLogDistCeiling(map);} else if (type == "WiFiModelPerFloor") {Log::add(name, "loading WiFiModelPerFloor"); mdl = new WiFiModelPerFloor(map);} else if (type == "WiFiModelPerBBox") {Log::add(name, "loading WiFiModelPerBBox"); mdl = new WiFiModelPerBBox(map);} else {throw Exception("invalid model type given: " + type);} // load the model from XML mdl->readFromXML(doc, src); // done return mdl; } #endif // WIFIMODELFACTORYIMPL_H