Logo Search packages:      
Sourcecode: fet version File versions

void Rules::removeActivity ( int  _id,
int  _activityGroupId 
)

If _activityGroupId==0, then this is a non-split activity (if >0, then this is a single sub-activity from a split activity. Removes this activity from the list of activities. For split activities, it removes all the sub-activities that are contained in it.

Definition at line 1675 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.

{
      for(Activity *act=this->activitiesList.first(); act; ){
            if(_id==act->id || _activityGroupId>0 && _activityGroupId==act->activityGroupId){
                  //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();

                  this->activitiesList.remove(); //if this is the last activity, then we will make one more comparison above
                  act=this->activitiesList.current();
            }
            else
                  act=this->activitiesList.next();
      }

      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