Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::removeEquipment ( const QString &  equipmentName  ) 

Removes the equipment with this name. Returns true on success, false on failure (not found).

Definition at line 1906 of file rules.cpp.

References equipmentsList, ConstraintSubjectRequiresEquipments::equipmentsNames, internalStructureComputed, Equipment::name, ConstraintSubjectRequiresEquipments::removeRequiredEquipment(), removeSpaceConstraint(), roomsList, searchEquipment(), and spaceConstraintsList.

{
      int i=this->searchEquipment(equipmentName);
      if(i<0)
            return false;

      Equipment* searchedEquipment=this->equipmentsList.at(i);
      assert(searchedEquipment->name==equipmentName);
      
      //check the constraints
      for(SpaceConstraint* ctr=this->spaceConstraintsList.first(); ctr; )
            if(ctr->type==CONSTRAINT_SUBJECT_REQUIRES_EQUIPMENTS){
                  ConstraintSubjectRequiresEquipments* csre=(ConstraintSubjectRequiresEquipments*)ctr;
                  QStringList::Iterator it;
                  for(it=csre->equipmentsNames.begin(); it!=csre->equipmentsNames.end(); it++)
                        if(*it==equipmentName)
                              break;
                  if(it!=csre->equipmentsNames.end()){
                        int tmp=csre->removeRequiredEquipment(equipmentName);
                        assert(tmp==1);
                  }

                  //remove the constraint if equipments list empty
                  if(csre->equipmentsNames.isEmpty()){
                        this->removeSpaceConstraint(ctr);
                        ctr=this->spaceConstraintsList.current();
                  }
                  else
                        ctr=this->spaceConstraintsList.next();
            }
            else
                  ctr=this->spaceConstraintsList.next();
      
      //Remove this equipment from all the rooms that posess it.
      for(Room* rm=this->roomsList.first(); rm; rm=this->roomsList.next())
            rm->removeEquipment(equipmentName);

      this->equipmentsList.remove(i);
      this->internalStructureComputed=false;
      return true;
}


Generated by  Doxygen 1.6.0   Back to index