#include "building.hh" #include "waypoint.hh" #include "area.hh" /*** Constructeurs ***/ Building::Building(const string &_name) { name = _name ; } Building::Building(const Building &b) { name = b.name ; areas = b.areas ; waypoints = b.waypoints ; } /* * Destructor * Note: deletes (unallocates) all elements in areas; deletes elements in * waypoints that belong only to this Building (waypoints that link) * several buildings are preserved). */ Building::~Building() { // Empty Area list for (vector::iterator i = areas.begin() ; i != areas.end() ; i++) delete *i ; areas.clear() ; // Empty Waypoint list for (vector::iterator i = waypoints.begin() ; i != waypoints.end() ; i++) { // Delete current waypoint only if it is not linked to another building if ((*i)->get_buildings().size() <= 1) delete *i ; } waypoints.clear() ; } /*** Accesseurs lecture ***/ string Building::get_name() const { return name ; } vector Building::get_areas() const { return areas ; } vector Building::get_waypoints() const { return waypoints ; } /*** Accesseurs écriture ***/ void Building::set_name(const string &_name) { name = _name ; } void Building::add_area(const Area *a) { areas.push_back((Area *) a) ; } void Building::add_waypoint(const Waypoint *wp) { waypoints.push_back((Waypoint *) wp) ; } /*** Opérateurs ***/ Building Building::operator=(const Building &b) { if (this == &b) return *this ; name = b.name ; areas = b.areas ; waypoints = b.waypoints ; return *this; } bool Building::operator==(const Building &b) const { if (this == &b) return true ; return name == b.name && areas == b.areas && waypoints == b.waypoints ; } bool Building::operator!=(const Building &b) const { return !(*this == b) ; } ostream& operator<<(ostream &os, const Building &b) { os << b.name ; return os ; }