Project

General

Profile

Task #3118

Updated by Yingdi Yu over 8 years ago

This is a draft abstraction for schedule. It consists of two classes. class. 

 Schedule **Schedule** 
 -------- ------------ 

 **Schedule** consists Schedule contains a list of RepetitiveIntervals. 

 Schedule itself contains a set start time and an end time, which defines the start point and the end point of **RepetitiveIntervals**. the schedule. 

 Schedule implements WireEncodable implement wire encode and WireDecodable concept decode to facilitate storage. support storage and transfer. 
 The class can support: 

 A +     An schedule contains two sets of RepetitiveIntervals: with a white list start time and an end time 
 +     An infinite schedule with a black list. 
 The accessible start time intervals of a schedule are those covered by one RepetitiveInterval only 

 ### Nested Class in the white list but not by any Schedule : RepetitiveInterval in the black list.  

 ### RepetitiveInterval 

 The element object in Schedule. A RepetitiveInterval is a time interval with the repeated repeat pattern. 

 RepetitiveInterval has six properties: startDate, endDate, intervalStartTime, intervalEndTime, repeatUnit, and nRepeats. 
 *startDate* and *endDate* are expressed as date, e.g., "20150822T000000"; 
 *intervalStartTime* and *intervalEndTime* are expressed as a particular hour in a day, i.e., an interval from 0 to 23; 
 *repeatUnit* is either day, month, or year; 
 *nRepeat* x *repeatUnit* is include the interval between two repetitions. start time, end time, repeat pattern, repeat unit, repeat end time. 

 One can interpret a RepetitiveInterval as: 
 "starting from *startDate*, repeat an interval from *intervalStartTime* implement wire encode and decode to *intervalEndTime* for every (*nRepeat* x *repeatUnit*) until *endDate*. support storage and transfer. 

 Note that: RepetitiveInterval can support: 

 +     *nRepeat* = 0 means no repetition An interval without any repeat pattern 
 +     *endDate* could be infinite An interval with a repeat pattern with/without a repeat end time 
 +     *repeatUnit* = day An interval with a repeat pattern and *nRepeat* = 7 is equivalent to repetition per week. a repeat unit with/without a repeat end time 

 An example of RepetitiveInterval would look every two day interval with an repeat end time object maybe like: 

 +     startDate: 20150822T000000 start time: 2015-08-20-14-00-00 
 +     endDate: 20160822T000000 end time: 2015-08-20-16-00-00 
 +     intervalStartTime: 16 repeat union: day 
 +     intervalEndTime: 18 repeat quantity: 2 
 +     repeatUnit: day repeat start time: 2015-08-18-00-00-00 
 +     nRepeat: 7 repeat end time: 2015-08-25-00-00-00 

 RepetitiveInterval also implements WireEncodable and WireDecodable concept to facilitate storage. 

 Interval **Interval** 
 -------- ------------ 

 A simple class which is used to be the return value of the functions in Schedule. 
 It only contains a start time and an end time. 
 It 

 Here is used to as the return value abstraction of some member methods of Schedule. 


 Class Interface these two classes: 
 --------------- ---------------------------------------------- 

     class Schedule 
     { 
     public: 
       ///@brief Construct an schedule 
       Schedule(); 
    
       Schedule(Block& block); 
    
     
    
       Schedule(TimePoint m_startTime; 
                TimePoint m_endTime); 

     public: 
       template<encoding::Tag TAG> 
       size_t 
       wireEncode(EncodingImpl<TAG>& encoder) const; 
    
       Block 
       wireEncode(); 

       void 
       wireDecode(); 

       ///@brief Add an RepetitiveInterval @p repetitiveInterval into white list a new repetitive interval 
       Schedule& 
       addWhiteInterval(RepetitiveInterval repetitiveInterval); addWhiteInterval(TimePoint startTime, 
                        TimePoint endTime, 
                        RepeatUnit Unit = RepetitiveInterval::NONE, 
                        TimePoint repeatStartTime = 0, 
                        TimePoint repeatEndTime = 0, 
                        size_T repeatQuantity = 0); 

       ///@brief Add the RepetitiveInterval into black list Delete an repetitive interval 
       Schedule& 
       addBlackInterval(RepetitiveInterval repetitiveInterval); 

       addBlackInterval(TimePoint startTime, 
                        TimePoint endTime, 
                        RepeatUnit Unit = RepetitiveInterval::NONE, 
                        TimePoint repeatStartTime = 0, 
                        TimePoint repeatEndTime = 0, 
                        size_T repeatQuantity = 0); 

      ///@brief Get the Interval that covers cover the @p ts 
       Interval 
       getCoveringInterval(const TimePoint& ts); 

     private: 
       std::set<RepetitiveInterval> m_whiteIntervalList; 
       std::set<RepetitiveInterval> m_blackIntervalList; 

       Block m_wire; 
     }; 

     class RepetitiveInterval 
     
       { 
     
       public: 
       
         enum class RepeatUnit{ 
         
           NONE = 0, 
         
           DAY = 1, 
         MONTH 
           WEEK = 2, 
         YEAR 
           MONTH = 3 
       }; 

     
         } 

       public: 
       
         RepetitiveInterval(); 

       

         RepetitiveInterval(Block& block); 

       

         RepetitiveInterval(TimePoint startDate, 
                          startTime, 
                            TimePoint endDate, 
                          Hour intervalStartTime, 
                          Hour intervalEndTime, 
                          size_t nRepeats endTime, 
                            RepeatUnit Unit = RepetitiveInterval::NONE, 
                            TimePoint repeatStartTime = 0, 
                          RepeatUnit unit 
                            TimePoint repeatEndTime = RepetitiveInterval::NONE); 

       0, 
                            size_T repeatQuantity = 0); 

         template<encoding::Tag TAG> 
       
         size_t 
       
         wireEncode(EncodingImpl<TAG>& encoder) const; 

       

         Block 
       
         wireEncode(); 

       

         void 
       
         wireDecode(); 

       

         ///@brief Check if the time point @p ts is covered by in the RepetitiveInterval 
       
         bool 
       covers(TimePoint 
         isInRepetitiveInterval(TimePoint tp); 

       

         ///@brief Get the covering interval for time point @p ts 
       
         Interval 
       getCoveringInterval(TimePoint tp); 

       
         getCoveringInterval(); 

         ///@brief To store in std::set 
       
         bool 
       operator<(RepetitiveInterval 
         operator <(RepetitiveInterval interval) const; 

       private: 
         TimePoint m_startDate; m_startTime; 
         TimePoint m_endDate; m_endTime; 

         RepeatUnit m_repeatUnit; 
         Hour m_intervalStartTime; size_t m_repeatQuantity; 
         Hour m_intervalEndTime; TimePoint m_repeatStartTime; 
         size_t m_nRepeats = 0; 
         RepeatUnit m_unit; TimePoint m_repeatEndTime; 

         Block m_wire; 
       }; 

     private: 
       TimePoint m_startTime; 
       TimePoint m_endTime; 
       std::set<RepetitiveInterval> m_whiteIntervalList; 
       std::set<RepetitiveInterval> m_blackIntervalList; 

       Block m_wire; 
     }; 

     class Interval 
     { 
     public: 
       Interval(TimePoint startTime, 
                TimePoint endTime); 

       bool 
       covers(TimePoint isInInterval(TimePoint tp); 

       Interval 
       operator&&(Interval getIntersection(Interval interval); 

     private: 
       TimePoint m_startTime; 
       TimePoint m_endTime; 
     };

Back