[Positioner] is_cp_coordinates(): return pointer

Stock::is_cp_coordinates() now returns a pointer to the CP if found, or
NULL if not found.
This commit is contained in:
Matteo Cypriani 2013-07-08 15:08:09 -04:00
parent 2ac9cc2c1d
commit 652ed7b706
2 changed files with 7 additions and 8 deletions

View File

@ -328,17 +328,16 @@ double Stock::cp_matrix_get_ss(const std::string &mac_transmitter,
/**
* @returns `true` if `coord` are the coordinates of an existing
* CP, `false` if not.
* @returns A const pointer to the CP `coord` is the coordinates of.
* @returns NULL if `coord` is not the coordinates of any CP.
*/
bool Stock::is_cp_coordinate(const Point3D &coord)
const CapturePoint* Stock::is_cp_coordinate(const Point3D &coord)
{
for (unordered_map<string, CapturePoint>::const_iterator cp =
cps.begin() ; cp != cps.end() ; ++cp)
for (auto cp = cps.begin() ; cp != cps.end() ; ++cp)
if (cp->second.get_coordinates() == coord)
return true ;
return &cp->second ;
return false ;
return NULL ;
}

View File

@ -144,7 +144,7 @@ public:
static double cp_matrix_get_ss(const std::string &mac_transmitter,
const std::string &mac_receiver) ;
/// Checks if a Point3D is the coordinate of an existing CP
static bool is_cp_coordinate(const Point3D &coord) ;
static const CapturePoint* is_cp_coordinate(const Point3D &coord) ;
//@}
/** @name ReferencePoint operations */