#include "waypoint.hh" using namespace std ; /*** Constructeurs ***/ Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p) { buildings.push_back((Building *) _b) ; } Waypoint::Waypoint(const Building *_b, const float &_x, const float &_y, const float &_z ): Point3D(_x, _y, _z) { buildings.push_back((Building *) _b) ; } Waypoint::~Waypoint() { buildings.clear() ; } /*** Accesseurs lecture ***/ Building* Waypoint::get_1st_building() const { try { return buildings.at(0) ; } catch (out_of_range &e) { return NULL ; } } vector Waypoint::get_buildings() const { return buildings ; } /*** Accesseurs écriture ***/ void Waypoint::add_building(const Building *_b) { buildings.push_back((Building *) _b) ; } /*** Opérateurs ***/ Waypoint Waypoint::operator=(const Waypoint &wp) { if (this == &wp) return *this ; this->Point3D::operator=(wp) ; buildings = wp.buildings ; return *this ; } bool Waypoint::operator==(const Waypoint &wp) const { if (this == &wp) return true ; return this->Point3D::operator==(wp) && buildings == wp.buildings ; } bool Waypoint::operator!=(const Waypoint &wp) const { return !(*this == wp) ; } ostream &operator<<(ostream &os, const Waypoint &wp) { // Coordinates os << (Point3D) wp ; // List of buildings if (wp.buildings.size() == 0) os << endl << "Belongs to no building!" ; else for (vector::const_iterator i = wp.buildings.begin() ; i < wp.buildings.end() ; i++) os << endl << *i ; return os ; }