changes from the laptop
- some should be the same as previous commit (sorry!) - some should be new: LINT checks, ...?
This commit is contained in:
42
sensors/radio/model/WiFiModelFactoryImpl.h
Normal file
42
sensors/radio/model/WiFiModelFactoryImpl.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user