owlps/owlps-positioning/waypoint.cc

74 lines
1.1 KiB
C++

#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() ;
}
/*** 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 ;
}
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<Building*>::const_iterator i = wp.buildings.begin() ;
i != wp.buildings.end() ; i++)
os << endl << *i ;
return os ;
}