214 {
215 map<string, Schedule> builtSchedules;
216 map<string, ScheduleData> derivedSchedules;
217
218
220 string schName = s.first;
221 ScheduleData& schData = s.second.first;
222 Schedule& sch = s.second.second;
223
224 if (!schData.hasDerived()) {
226 builtSchedules[schName] = sch;
227 } else {
228 derivedSchedules[schName] = schData;
229 }
230 }
231
232
233 bool calculated;
234 while (derivedSchedules.size() > 0) {
235 calculated = false;
236 for (auto& ds : derivedSchedules) {
237 string dsName = ds.first;
238 ScheduleData& dsSchedData = ds.second;
239 vector<string> baseNames = dsSchedData.baseScheduleNames();
240 for (string& bn : baseNames) {
241 QL_REQUIRE(builtSchedules.find(bn) != builtSchedules.end(), "Could not find base schedule \" " << bn << "\" for derived schedule \" " << dsName << "\"");
242 }
243 Schedule schedule;
244 schedule =
makeSchedule(dsSchedData, openEndDateReplacement, builtSchedules);
245 schedules_.find(dsName)->second.second = schedule;
246 builtSchedules[dsName] = schedule;
247 derivedSchedules.erase(dsName);
248 calculated = true;
249 break;
250 }
251
252
253
254 if (!calculated) {
255 for (auto& ds : derivedSchedules)
256 ALOG(
"makeSchedules(): could not find base schedule \"" << ds.first <<
"\"");
257 QL_FAIL("makeSchedules(): failed to build at least one derived schedule");
258 break;
259 }
260 }
261}
#define ALOG(text)
Logging Macro (Level = Alert)
Schedule makeSchedule(const ScheduleDates &data)