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 regularDateSchedule{sd1, timepiece_move::rewind,
                                       timepiece_settings{.inverseFixedDuration = fixed_duration_as::inverse_fixed_duration}};
schedule_timepiece fixedDateSchedule{sd2, timepiece_move::rewind,
                                     timepiece_settings{.inverseFixedDuration = fixed_duration_as::inverse_fixed_duration,
                                                        .dateAdjustmentRule{us_federal_holiday_observance_rule}}};
schedule_timepiece inaugurationSchedule{sd3, timepiece_move::rewind,
                                        timepiece_settings{.inverseFixedDuration = fixed_duration_as::inverse_fixed_duration,
                                                           .dateAdjustmentRule{us_inauguration_day_observance_rule}}};
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 readAppData = [](const boost::property_tree::ptree& scheduleItem, interval_schedule_data* data) {
    schedule_appdata appdata;

    if (is_category(data->blueprint, onset_series_duration_blueprint)) {
        const string durationAs = scheduleItem.get<string>("fd:fixed_duration_as", "uptime");
        appdata.inverseFixedDuration = fixed_duration_as(durationAs == "downtime");
    }

    if ((data->blueprint == onset_series_blueprint::fixed_subrange_duration ||
         data->blueprint == onset_series_blueprint::subrange_interval) &&
        data->interval.granularity == year_interval) {
        u8string rule(from_range, scheduleItem.get<string>("fd:calendar_date_adjustment_rule", ""));

        appdata.calendarDateAdjustmentRule = std::move(rule);
    }

    data->appdata = std::move(appdata);
};

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

// filter valid schedules
auto validScheduleDefs = scheduleDefs | 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 : validScheduleDefs) {
    auto& appdata = any_cast<const schedule_appdata&>(def.app_data());

    schedules.emplace_back(def, natural_timepiece_move_setup(def.data(), scheduling_purpose::application_uptime),
                           timepiece_settings{.inverseFixedDuration = appdata.inverseFixedDuration,
                                              .dateAdjustmentRule = appdata.calendarDateAdjustmentRule});
}

Complete US Federal Holidays + Restart_fromXML.cpp


PrevUpHomeNext