MissionMgr.cc
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* 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 */