- some should be the same as previous commit (sorry!) - some should be new: LINT checks, ...?
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#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") {mdl = new WiFiModelLogDist();}
|
|
else if (type == "WiFiModelLogDistCeiling") {mdl = new WiFiModelLogDistCeiling(map);}
|
|
else if (type == "WiFiModelPerFloor") {mdl = new WiFiModelPerFloor(map);}
|
|
else if (type == "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
|