PrevUpHomeNext

Complete schedule

XML

Complete US Federal Holidays + Restart.xml

C++

The following listing shows how to:

  1. Construct timepoint generators from the various schedule data objects defined above.
using fixed_duration_as = timepiece_settings::fixed_duration_as;

schedule_timepiece schedule1{sd1, timepiece_move::rewind, any_cast<fixed_duration_as>(sd1.appdata)};
schedule_timepiece schedule2{sd2, timepiece_move::rewind, any_cast<fixed_duration_as>(sd2.appdata)};
schedule_timepiece schedule3{sd3, timepiece_move::rewind, any_cast<fixed_duration_as>(sd3.appdata)};
schedule_timepiece restartSchedule{sd4};

Complete US Federal Holidays + Restart.cpp

C++ from XML

The following listing shows how to:

  1. Read a schedule from a (validated) XML file.
  2. Handle reading the fd:fixed_duration_as attribute.
  3. Construct timepoint generators from the various schedule data objects defined in the xml file.
using fixed_duration_as = timepiece_settings::fixed_duration_as;

constexpr auto determineDowntime = [](const boost::property_tree::ptree& scheduleItem, interval_schedule_data* data) {
    if (is_category(data->blueprint, onset_series_duration_blueprint)) {
        string durAs = scheduleItem.get<string>("fd:fixed_duration_as", "uptime");
        data->appdata = fixed_duration_as(durAs == "downtime");
    }
};

ifstream is{L"Complete US Federal Holidays + Restart.xml"};
vector<interval_schedule_definition> schedules = read_xml_interval_schedule(is, determineDowntime);
is.close();

// filter valid schedules
auto validSchedules = schedules | std::views::filter([](const interval_schedule_definition& schedule) {
                          return !schedule.inactive() && !schedule.data().cycle.empty();
                      });

// construct timepoint generators
list<schedule_timepiece> schedules_;
// start at currently active interval,
// (except if activity boundary is today, which is taken care of by the interval schedule)
for (const interval_schedule_definition& def : validSchedules) {
    const fixed_duration_as* durAs = any_cast<fixed_duration_as>(&def.app_data());

    schedules_.emplace_back(def, natural_timepiece_move_setup(def.data(), scheduling_purpose::application_uptime),
                            timepiece_settings{def.is_duration_blueprint() ? *durAs : fixed_duration_as::fixed_duration});
}

Complete US Federal Holidays + Restart_fromXML.cpp


PrevUpHomeNext