25 parseTree(complete_filename);
28 auto schedule_config = m_pt.get_child(
"travel_schedule");
31 for (
auto it = schedule_config.begin(); it != schedule_config.end(); it++) {
33 Flight new_flight = parseFlight(it->second);
42 boost::property_tree::read_xml(filename, m_pt);
44 throw invalid_argument(
"In TravellerScheduleReader: Error while parsing.");
49 string source_sim = node.get<
string>(
"direction.<xmlattr>.src");
50 string destination_sim = node.get<
string>(
"direction.<xmlattr>.dest");
52 int amount = node.get<
int>(
"<xmlattr>.amount");
54 throw invalid_argument(
"In TravellerScheduleReader: Invalid amount of travellers.");
57 int duration = node.get<
int>(
"<xmlattr>.duration");
59 throw invalid_argument(
"In TravellerScheduleReader: Invalid duration.");
62 int day_of_the_week = node.get<
int>(
"<xmlattr>.day_of_the_week");
63 if (day_of_the_week < 0 || day_of_the_week > 6) {
64 throw invalid_argument(
"In TravellerScheduleReader: Invalid day of the week.");
67 string district = node.get<
string>(
"arrival.<xmlattr>.district");
68 string facility = node.get<
string>(
"arrival.<xmlattr>.facility");
70 return Flight(source_sim, destination_sim,
uint(amount),
uint(duration),
uint(day_of_the_week), district, facility);
Interface for install directory queries.
Schedule readSchedule(string filename)
Expects a worthy path.
Time Dependent Person DataType.
static boost::filesystem::path getDataDir()
Utility method: get path to the directory for data files.
array< vector< Flight >, 7 > Schedule
bool operator==(const GeoCoordinate &coord1, const GeoCoordinate &coord2)
void parseTree(string filename)
Flight parseFlight(boost::property_tree::ptree &node) const