24 #include <boost/algorithm/string.hpp>
25 #include <boost/property_tree/ptree.hpp>
37 if (day ==
"wednesday")
39 if (day ==
"thursday")
43 if (day ==
"saturday")
45 ASSERT_LOG(0,
"{" << day <<
"} is not a valid day of the week.");
53 for (
const auto &sched : schedules_tree)
55 const std::string &node_name = sched.first;
56 const boost::property_tree::ptree &node = sched.second;
58 if (node_name !=
"schedule")
60 std::string err =
"Invalid configuration file content. Expected a XML "
61 "node named 'schedule' but found " +
62 node_name +
" instead.";
73 std::string schedule_name = node.get<std::string>(
"name");
78 for (
const auto &sched_data : node)
80 if (sched_data.first ==
"name")
82 std::string start = sched_data.second.get<std::string>(
"start");
83 std::string end = sched_data.second.get<std::string>(
"end");
84 std::vector<std::string> temp;
86 boost::split(temp, start, boost::is_any_of(
":"));
89 int start_hour = std::stoi(temp[0]);
90 int start_min = std::stoi(temp[1]);
93 boost::split(temp, end, boost::is_any_of(
":"));
96 int end_hour = std::stoi(temp[0]);
97 int end_min = std::stoi(temp[1]);
100 start_min, end_hour, end_min);
101 sched.add_timeframe(tf);
104 INFO(
"A schedule with name " << schedule_name
105 <<
" already exists. It will be overridden.");
107 schedules_[schedule_name] = std::make_shared<Schedule>(sched);