Logo Search packages:      
Sourcecode: fet version File versions

void Rules::removeActivity ( int  _id  ) 

Removes only the activity with this id.

Definition at line 1497 of file rules.cpp.

References activitiesList, ConstraintActivityEndsDay::activityId, ConstraintActivityPreferredTimes::activityId, ConstraintActivityPreferredTime::activityId, Constraint2ActivitiesGrouped::firstActivityId, Constraint2ActivitiesConsecutive::firstActivityId, Constraint2ActivitiesGrouped::getDescription(), Constraint2ActivitiesConsecutive::getDescription(), ConstraintActivityEndsDay::getDescription(), ConstraintActivityPreferredTimes::getDescription(), ConstraintActivityPreferredTime::getDescription(), internalStructureComputed, removeSpaceConstraint(), removeTimeConstraint(), Constraint2ActivitiesGrouped::secondActivityId, Constraint2ActivitiesConsecutive::secondActivityId, spaceConstraintsList, and timeConstraintsList.

Referenced by removeGroup(), removeSubgroup(), removeSubject(), removeTeacher(), and removeYear().

{
      for(Activity *act=this->activitiesList.first(); act; act=this->activitiesList.next())
            if(_id==act->id){
                  //removing ConstraintActivityPreferredTime-s referring to this activity
                  for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
                        if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_TIME){
                              ConstraintActivityPreferredTime *apt=(ConstraintActivityPreferredTime*)ctr;
                              if(apt->activityId==act->id){
                                    cout<<"Removing constraint "<<(apt->getDescription(*this))<<endl;
                                    this->removeTimeConstraint(ctr);
                                    ctr=this->timeConstraintsList.current();
                              }
                              else
                                    ctr=this->timeConstraintsList.next();
                        }
                        else
                              ctr=this->timeConstraintsList.next();
                  }
                  //removing ConstraintActivityPreferredTimes-s referring to this activity
                  for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
                        if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_TIMES){
                              ConstraintActivityPreferredTimes *apt=(ConstraintActivityPreferredTimes*)ctr;
                              if(apt->activityId==act->id){
                                    cout<<"Removing constraint "<<(apt->getDescription(*this))<<endl;
                                    this->removeTimeConstraint(ctr);
                                    ctr=this->timeConstraintsList.current();
                              }
                              else
                                    ctr=this->timeConstraintsList.next();
                        }
                        else
                              ctr=this->timeConstraintsList.next();
                  }
                  //removing ConstraintActivityEndsDay-s referring to this activity
                  for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
                        if(ctr->type==CONSTRAINT_ACTIVITY_ENDS_DAY){
                              ConstraintActivityEndsDay *apt=(ConstraintActivityEndsDay*)ctr;
                              if(apt->activityId==act->id){
                                    cout<<"Removing constraint "<<(apt->getDescription(*this))<<endl;
                                    this->removeTimeConstraint(ctr);
                                    ctr=this->timeConstraintsList.current();
                              }
                              else
                                    ctr=this->timeConstraintsList.next();
                        }
                        else
                              ctr=this->timeConstraintsList.next();
                  }
                  //removing Constraint2ActivitiesConsecutive-s referring to this activity
                  for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
                        if(ctr->type==CONSTRAINT_2_ACTIVITIES_CONSECUTIVE){
                              Constraint2ActivitiesConsecutive *apt=(Constraint2ActivitiesConsecutive*)ctr;
                              if(apt->firstActivityId==act->id || apt->secondActivityId==act->id){
                                    cout<<"Removing constraint "<<(apt->getDescription(*this))<<endl;
                                    this->removeTimeConstraint(ctr);
                                    ctr=this->timeConstraintsList.current();
                              }
                              else
                                    ctr=this->timeConstraintsList.next();
                        }
                        else
                              ctr=this->timeConstraintsList.next();
                  }
                  //removing Constraint2ActivitiesGrouped-s referring to this activity
                  for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; ){
                        if(ctr->type==CONSTRAINT_2_ACTIVITIES_GROUPED){
                              Constraint2ActivitiesGrouped *apt=(Constraint2ActivitiesGrouped*)ctr;
                              if(apt->firstActivityId==act->id || apt->secondActivityId==act->id){
                                    cout<<"Removing constraint "<<(apt->getDescription(*this))<<endl;
                                    this->removeTimeConstraint(ctr);
                                    ctr=this->timeConstraintsList.current();
                              }
                              else
                                    ctr=this->timeConstraintsList.next();
                        }
                        else
                              ctr=this->timeConstraintsList.next();
                  }

                  //removing ConstraintActivityPreferredRoom-s referring to this activity
                  for(SpaceConstraint* ctr=this->spaceConstraintsList.first(); ctr; )
                        if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOM){
                              if(((ConstraintActivityPreferredRoom*)ctr)->activityId==act->id){
                                    this->removeSpaceConstraint(ctr);
                                    ctr=this->spaceConstraintsList.current();
                              }
                              else
                                    ctr=this->spaceConstraintsList.next();
                        }
                        else
                              ctr=this->spaceConstraintsList.next();
                  //removing ConstraintActivityPreferredRooms-s referring to this activity
                  for(SpaceConstraint* ctr=this->spaceConstraintsList.first(); ctr; )
                        if(ctr->type==CONSTRAINT_ACTIVITY_PREFERRED_ROOMS){
                              if(((ConstraintActivityPreferredRooms*)ctr)->activityId==act->id){
                                    this->removeSpaceConstraint(ctr);
                                    ctr=this->spaceConstraintsList.current();
                              }
                              else
                                    ctr=this->spaceConstraintsList.next();
                        }
                        else
                              ctr=this->spaceConstraintsList.next();

                  //remove the activity
                  this->activitiesList.remove(); 
                  break;
            }

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_MIN_N_DAYS_BETWEEN_ACTIVITIES){
                  ((ConstraintMinNDaysBetweenActivities*)ctr)->removeUseless(*this);
                  if(((ConstraintMinNDaysBetweenActivities*)ctr)->n_activities<2){
                        this->removeTimeConstraint(ctr);
                        ctr=this->timeConstraintsList.current();
                  }
                  else
                        ctr=this->timeConstraintsList.next();
            }
            else
                  ctr=this->timeConstraintsList.next();

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME){
                  ((ConstraintActivitiesSameStartingTime*)ctr)->removeUseless(*this);
                  if(((ConstraintActivitiesSameStartingTime*)ctr)->n_activities<2){
                        this->removeTimeConstraint(ctr);
                        ctr=this->timeConstraintsList.current();
                  }
                  else
                        ctr=this->timeConstraintsList.next();
            }
            else
                  ctr=this->timeConstraintsList.next();

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR){
                  ((ConstraintActivitiesSameStartingHour*)ctr)->removeUseless(*this);
                  if(((ConstraintActivitiesSameStartingHour*)ctr)->n_activities<2){
                        this->removeTimeConstraint(ctr);
                        ctr=this->timeConstraintsList.current();
                  }
                  else
                        ctr=this->timeConstraintsList.next();
            }
            else
                  ctr=this->timeConstraintsList.next();

      for(TimeConstraint* ctr=this->timeConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING){
                  ((ConstraintActivitiesNotOverlapping*)ctr)->removeUseless(*this);
                  if(((ConstraintActivitiesNotOverlapping*)ctr)->n_activities<2){
                        this->removeTimeConstraint(ctr);
                        ctr=this->timeConstraintsList.current();
                  }
                  else
                        ctr=this->timeConstraintsList.next();
            }
            else
                  ctr=this->timeConstraintsList.next();

      for(SpaceConstraint* ctr=this->spaceConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_ACTIVITIES_SAME_ROOM){
                  ((ConstraintActivitiesSameRoom*)ctr)->removeUseless(*this);
                  if(((ConstraintActivitiesSameRoom*)ctr)->n_activities<2){
                        this->removeSpaceConstraint(ctr);
                        ctr=this->spaceConstraintsList.current();
                  }
                  else
                        ctr=this->spaceConstraintsList.next();
            }
            else
                  ctr=this->spaceConstraintsList.next();

      this->internalStructureComputed=false;
}


Generated by  Doxygen 1.6.0   Back to index