#include "building.hh" #include "area.hh" #include "waypoint.hh" using namespace std ; /* *** Constructors *** */ /** * 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::const_iterator i = areas.begin() ; i != areas.end() ; ++i) delete *i ; areas.clear() ; // Empty Waypoint list for (vector::const_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() ; } /* *** Operators *** */ const Building& Building::operator=(const Building &source) { if (this == &source) return *this ; name = source.name ; areas = source.areas ; waypoints = source.waypoints ; return *this; } bool Building::operator==(const Building &source) const { if (this == &source) return true ; return name == source.name && areas == source.areas && waypoints == source.waypoints ; } ostream& operator<<(ostream &os, const Building &b) { os << b.name ; return os ; }