Back to index

fet  5.18.0
room.cpp
Go to the documentation of this file.
00001 //
00002 //
00003 // Description: This file is part of FET
00004 //
00005 //
00006 // Author: Liviu Lalescu <Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)>
00007 // Copyright (C) 2003 Liviu Lalescu <http://lalescu.ro/liviu/>
00008 //
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016   ***************************************************************************/
00017 
00018 #include "room.h"
00019 #include "rules.h"
00020 
00021 Room::Room()
00022 {
00023        this->capacity=MAX_ROOM_CAPACITY;
00024        this->building="";
00025 }
00026 
00027 Room::~Room()
00028 {
00029 }
00030 
00031 void Room::computeInternalStructure(Rules& r)
00032 {
00033        if(building=="")
00034               buildingIndex=-1;
00035        else{
00036               buildingIndex=r.searchBuilding(building);
00037               assert(buildingIndex>=0 && buildingIndex<r.nInternalBuildings);
00038        }
00039 }
00040 
00041 QString Room::getDescription()
00042 {
00043        QString s=tr("N:%1", "Name of room").arg(this->name);
00044        s+=", ";
00045        
00046        if(this->building!=""){
00047               s+=tr("B:%1", "Building").arg(this->building);
00048               s+=", ";
00049        }
00050        /*s+=tr("T:");
00051        s+=this->type;
00052        s+=",";*/
00053        s+=tr("C:%1", "Capacity").arg(CustomFETString::number(this->capacity));
00054        //s+=",";
00055 
00056        /*for(QStringList::Iterator it=this->equipments.begin(); it!=this->equipments.end(); it++)
00057               s+="E:"+(*it)+", ";*/
00058 
00059        return s;
00060 }
00061 
00062 QString Room::getDetailedDescription()
00063 {
00064        QString s=tr("Room");
00065        s+="\n";
00066        s+=tr("Name=%1", "The name of the room").arg(this->name);
00067        s+="\n";
00068 
00069        if(this->building!=""){
00070               s+=tr("Building=%1").arg(this->building);
00071               s+="\n";
00072        }
00073        /*s+=tr("Type=");
00074        s+=this->type;
00075        s+="\n";*/
00076        s+=tr("Capacity=%1").arg(CustomFETString::number(this->capacity));
00077        s+="\n";
00078 
00079        /*for(QStringList::Iterator it=this->equipments.begin(); it!=this->equipments.end(); it++)
00080               s+="Equipment="+(*it)+"\n";*/
00081 
00082        return s;
00083 }
00084 
00085 QString Room::getXmlDescription()
00086 {
00087        QString s="<Room>\n";
00088        s+="   <Name>"+protect(this->name)+"</Name>\n";
00089        s+="   <Building>"+protect(this->building)+"</Building>\n";
00090        //s+=" <Type>"+protect(this->type)+"</Type>\n";
00091        s+="   <Capacity>"+CustomFETString::number(this->capacity)+"</Capacity>\n";
00092        
00093        /*for(QStringList::Iterator it=this->equipments.begin(); it!=this->equipments.end(); it++)
00094               s+="   <Equipment>"+protect(*it)+"</Equipment>\n";*/
00095        
00096        s+="</Room>\n";
00097 
00098        return s;
00099 }
00100 
00101 QString Room::getDetailedDescriptionWithConstraints(Rules& r)
00102 {
00103        QString s=this->getDetailedDescription();
00104 
00105        s+="--------------------------------------------------\n";
00106        s+=tr("Space constraints directly related to this room:");
00107        s+="\n";
00108        for(int i=0; i<r.spaceConstraintsList.size(); i++){
00109               SpaceConstraint* c=r.spaceConstraintsList[i];
00110               if(c->isRelatedToRoom(this)){
00111                      s+="\n";
00112                      s+=c->getDetailedDescription(r);
00113               }
00114        }
00115        s+="--------------------------------------------------\n";
00116 
00117        return s;
00118 }
00119 
00120 int roomsAscending(const Room* r1, const Room* r2)
00121 {
00122        return r1->name < r2->name;
00123 }