MissionMgr.cc 1.14 KB
/*
 * MissionMgr.cc
 *
 *  Created on: Oct 6, 2014
 *      Author: m.mazel
 */

#include "Helper.hh"
#include "Properties.hh"
#include "MissionMgr.hh"
#include "MissionParser.hh"
#include "InfoLogger.hh"

namespace AMDA {
namespace Info {

const MissionInfoSPtr MissionMgr::getMissionInfoFromId (const std::string &id) {
	if (id.empty())
		return MissionInfoSPtr();

	// If Mission id already loaded, return it
	if (_missionInfoMap.find (id) != _missionInfoMap.end()) {
		return _missionInfoMap [id];
	}

	// Otherwise, build Mission path & filename using the id
	AMDA::helpers::Properties lProperties("app.properties");

	std::string xmlFileName = lProperties["app.missionInfo.path"] + "/" + id + ".xml";
	_missionInfoMap [id] = getMissionInfoFromFile (xmlFileName);
	return _missionInfoMap [id];
}

MissionInfoSPtr MissionMgr::getMissionInfoFromFile (const std::string &xmlFilename) {
	AMDA::helpers::Properties lProperties("app.properties");

	// Retrieve XSD file for Mission and build a parser
	MissionParser parser(lProperties["app.missionInfo.xsd"].c_str());

	// Parse XML file
	return parser.parse (xmlFilename);
}

} /* namespace Info */
} /* namespace AMDA */