From 652ed7b70640f61890a00adf2fc1ed1107e9882c Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Mon, 8 Jul 2013 15:08:09 -0400 Subject: [PATCH] [Positioner] is_cp_coordinates(): return pointer Stock::is_cp_coordinates() now returns a pointer to the CP if found, or NULL if not found. --- owlps-positioner/stock.cc | 13 ++++++------- owlps-positioner/stock.hh | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/owlps-positioner/stock.cc b/owlps-positioner/stock.cc index 935b5c5..2fda1b5 100644 --- a/owlps-positioner/stock.cc +++ b/owlps-positioner/stock.cc @@ -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::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 ; } diff --git a/owlps-positioner/stock.hh b/owlps-positioner/stock.hh index a490b2c..b36fd6e 100644 --- a/owlps-positioner/stock.hh +++ b/owlps-positioner/stock.hh @@ -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 */