Project

General

Profile

Task #3118

Updated by Zhiyi Zhang over 8 years ago

    This is a draft abstraction for schedule. It consists of two class. One is Schedule, another is Agenda(maybe there's a better name), which is the element in Schedule. 
   Here is the abstraction: 


     
 class Schedule 
     
 { 
     
 public: 
     
 ///@brief Construct an empty schedule 
     
 Schedule(); 

     

 ///@brief Add a new agenda, if there's a conflict, the agenda will use the union set           of the agendas 
     
 Schedule& 
     
 addAgenda(Agenda); 

     

 ///@brief Delete an agenda, if the agenda covers time that is not in existing agenda, this part time will be omitted 
     
 Schedule& 
     
 deleteAgenda(Agenda); 

     

 ///@brief Change an existing agenda, replace the old one 
     
 Schedule& 
     
 replaceAgenda(Agenda, Agenda); 

     

 ///@brief Get the agenda that cover the ts 
     
 Agenda 
     
 getAgenda(const TimePoint& ts); 

     

 private: 
     
 ///@brief Check if two agenda is conflicted 
     
 bool 
     
 isConflict(Agenda, Agenda); 

     

 std::list<Agenda> m_agendaList; 
     }; 

     
 } 

 class Agenda 
     
 { 
     
 public: 
     
 enum RepeatPattern{ 
     
 NONE = 0, 
     
 EVERY_DAY = 1, 
     
 EVERY_WEEK = 2, 
     
 EVERY_MONTH = 3 
     
 } 

     

 public: 
     
 ///@brief The construction, once the object is created, it becomes read-only 
     
 Agenda(TimePoint startTime, 
                  
              TimePoint endTime); 

     

 Agenda(TimePoint startTime, 
                  
              TimePoint endTime, 
                  
              RepeatPattern pattern, 
                  
              TimePoint repeatEndTime); 

     

 ///@brief Get the start time of the agenda 
     
 TimePoint 
     
 getStartTime(); 

     

 ///@brief Get the end time of the agenda 
     
 TimePoint 
     
 getEndTime(); 

     

 ///@brief Get the repeat pattern of the agenda 
     
 RepeatPattern 
     
 getRepeatPattern(); 

     

 ///@brief Check if the time point is in the agenda 
     
 bool 
     
 isInAgenda(TimePoint tp); 

     

 ///@brief Check if two agendas are same 
     
 bool 
     
 equals(Agenda); 

     

 ///@brief reload the operator == 
     
 bool 
     
 operator==(const Agenda& agenda) const; 

     

 private: 
     
 TimePoint m_startTime; 
     
 TimePoint m_endTime; 
     
 RepeatPattern m_repeatPattern; 
     
 TimePoint m_repeatEndTime; 
     }; 
 } 

Back