PrevUpHomeNext

Class multi_timepiece_test_player

fd::multi_timepiece_test_player — A test player for multiple timepieces.

Synopsis

// In header: <fd/multi_timepiece_test_player.h>


class multi_timepiece_test_player {
public:
  // types
  typedef void(const schedule_timepiece &, const schedule_timepoint &, zeitgeber_timepoint_type) callback_signature;
  typedef std::function< callback_signature >                                                    callback_type;     

  // member classes/structs/unions

  struct final_parameters :
    public fd::multi_timepiece_test_player::parameters
  {

    // public member functions
    schedule_time_bounds time_bounds() const;

    // public data members
    schedule_timepoint upperBound;
    interval_spec maxInterval;
  };

  struct parameters {

    // private static functions
    template<bool = true> static scheduling_purpose default_purpose() noexcept;

    // public data members
    scheduling_purpose purpose;
    schedule_timepoint now;
    std::optional< int > nSets;
    bool suppress_contiguously_up_or_down;
  };

  struct State {
    // member classes/structs/unions

    struct PerSchedule {

      // public member functions
      bool operator<(const PerSchedule &) const;
      PerSchedule & operator=(const PerSchedule &) = delete;

      // public data members
      schedule_timepiece & schedule;
      const std::ptrdiff_t scheduleIdx;
      const int nInitialReps;
      const bool beganWithinInterval;
      schedule_timepoint now;
      bool inScope;
      bool(* handle_execution_or_termination;
    };

    // public member functions
    State(std::reference_wrapper< const multi_timepiece_test_player::final_parameters >, 
          std::reference_wrapper< std::list< schedule_timepiece > >, 
          multi_timepiece_test_player::callback_type &&);
    State(const State &) = delete;
    bool force_handler_call() const;
    bool test_limit_reached() const noexcept;

    // public static functions
    static bool handle_task_execution(State &, PerSchedule &);
    static bool handle_app_action_termination(State &, PerSchedule &);
    static bool handle_app_action_launch(State &, PerSchedule &);
    static bool handle_app_uptime_termination(State &, PerSchedule &);
    static bool handle_app_uptime_launch(State &, PerSchedule &);
    static bool handle_app_downtime_termination(State &, PerSchedule &);
    static bool handle_app_downtime_launch(State &, PerSchedule &);

    // public data members
    const multi_timepiece_test_player::final_parameters & params;
    std::list< schedule_timepiece > & schedules;
    const multi_timepiece_test_player::callback_type f;
    const scheduling_purpose purpose;
    const schedule_timepoint testLimitPoint;
    std::multiset< PerSchedule > ongoing;
  };

  // public member functions
  template<zeitgeber_setup_view SrcView> 
    multi_timepiece_test_player(parameters, SrcView);
  const final_parameters & get_parameters() const;
  const std::list< schedule_timepiece > & get_schedules() const;
  void play(callback_type);
};

Description

The player runs each schedule individually like the player for a single timepiece but in the order of their scheduled time points.

multi_timepiece_test_player public member functions

  1. template<zeitgeber_setup_view SrcView> 
      multi_timepiece_test_player(parameters params, SrcView defs);
    Construct the test player.
  2. const final_parameters & get_parameters() const;
  3. const std::list< schedule_timepiece > & get_schedules() const;
  4. void play(callback_type f);

PrevUpHomeNext