/* * DataSetMgr.cc * * Created on: Oct 6, 2014 * Author: m.mazel */ #include "Helper.hh" #include "Properties.hh" #include "DataSetMgr.hh" #include "DataSetParser.hh" #include "InfoLogger.hh" namespace AMDA { namespace Info { const DataSetInfoSPtr DataSetMgr::getDataSetInfoFromId (const std::string &id, bool forceCreateIfNoExist) { if (id.empty()) return DataSetInfoSPtr(); // If dataset id already loaded, return it if (_dataSetInfoMap.find (id) != _dataSetInfoMap.end()) { return _dataSetInfoMap [id]; } // Otherwise, build DataSet path & filename using the id AMDA::helpers::Properties lProperties("app.properties"); std::string xmlFileName = lProperties["app.dataSetInfo.path"] + "/" + id + ".xml"; _dataSetInfoMap [id] = getDataSetInfoFromFile (xmlFileName); if (forceCreateIfNoExist && (_dataSetInfoMap [id] == nullptr)) { _dataSetInfoMap [id] = DataSetInfoSPtr(new DataSetInfo); _dataSetInfoMap [id]->setId(id); } return _dataSetInfoMap [id]; } DataSetInfoSPtr DataSetMgr::getDataSetInfoFromFile (const std::string &xmlFilename) { AMDA::helpers::Properties lProperties("app.properties"); // Retrieve XSD file for DataSet and build a parser DataSetParser parser(lProperties["app.dataSetInfo.xsd"].c_str()); // Parse XML file return parser.parse (xmlFilename); } } /* namespace Info */ } /* namespace AMDA */