[Positioner] Work on const function arguments
The function arguments were reviewed to add missing 'const' keywords, and some classes were modified more deeply to make some pointer class variables constant.
This commit is contained in:
parent
69e8b49300
commit
a495d51f02
5
TODO.t2t
5
TODO.t2t
|
@ -45,11 +45,6 @@ Work to do in OwlPS
|
|||
information. This will make easier to develop clients in other
|
||||
languages than C and over other protocols than UDP.
|
||||
|
||||
- Mark arguments as const in function headers if needed
|
||||
|
||||
Mostly done in the Positioner C++ code (to be checked).
|
||||
//Done in lib* and other C modules.//
|
||||
|
||||
- Use struct ether_addr to store MAC addresses?
|
||||
|
||||
We could use the struct ether_addr to store binary MAC addresses, and
|
||||
|
|
|
@ -23,9 +23,9 @@ using namespace std ;
|
|||
/* *** Constructors *** */
|
||||
|
||||
|
||||
Area::Area(const Building *_building, const string &_name,
|
||||
Area::Area(const Building *const _building, const string &_name,
|
||||
const Point3D &p1, const Point3D &p2):
|
||||
building(const_cast<Building*>(_building)), name(_name)
|
||||
building(_building), name(_name)
|
||||
{
|
||||
set_coordinates(p1, p2) ;
|
||||
}
|
||||
|
|
|
@ -26,15 +26,16 @@ class Building ;
|
|||
class Area
|
||||
{
|
||||
protected:
|
||||
Building *building ; ///< The Building in which the Area is
|
||||
std::string name ;
|
||||
const Building *building ; ///< Building in which the Area is
|
||||
std::string name ; ///< Name of the Area
|
||||
Point3D p_min ; ///< First coordinate of the Area
|
||||
Point3D p_max ; ///< Second coordinate of the Area
|
||||
|
||||
void reorder_coordinates(void) ; ///< Reorders #p_min and #p_max
|
||||
/// Reorders #p_min and #p_max
|
||||
void reorder_coordinates(void) ;
|
||||
|
||||
public:
|
||||
Area(const Building *_building = NULL,
|
||||
Area(const Building *const _building = NULL,
|
||||
const std::string &_name = "Unnamed area",
|
||||
const Point3D &p1 = Point3D(0,0,0),
|
||||
const Point3D &p2 = Point3D(0,0,0)) ;
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
|
||||
/** @name Read accessors */
|
||||
//@{
|
||||
Building* get_building(void) const ;
|
||||
const Building* get_building(void) const ;
|
||||
const std::string& get_name(void) const ;
|
||||
const Point3D& get_p_min(void) const ;
|
||||
const Point3D& get_p_max(void) const ;
|
||||
|
@ -55,7 +56,7 @@ public:
|
|||
|
||||
/** @name Write accessors */
|
||||
//@{
|
||||
void set_building(const Building *_building) ;
|
||||
void set_building(const Building *const _building) ;
|
||||
void set_name(const std::string &_name) ;
|
||||
/// Sets the coordinates of the Area and reorder them
|
||||
void set_coordinates(const Point3D &p1, const Point3D &p2) ;
|
||||
|
@ -83,7 +84,7 @@ public:
|
|||
/* *** Read accessors *** */
|
||||
|
||||
|
||||
inline Building* Area::get_building() const
|
||||
inline const Building* Area::get_building() const
|
||||
{
|
||||
return building ;
|
||||
}
|
||||
|
@ -111,9 +112,9 @@ inline const Point3D& Area::get_p_max() const
|
|||
/* *** Write accessors *** */
|
||||
|
||||
|
||||
inline void Area::set_building(const Building *_building)
|
||||
inline void Area::set_building(const Building *const _building)
|
||||
{
|
||||
building = const_cast<Building*>(_building) ;
|
||||
building = _building ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void Autocalibration::generate_reference_point()
|
|||
cr.set_time_sent(cr.get_time_received()) ;
|
||||
cr.set_mobile(&mobile) ;
|
||||
cr.set_measurements(measurements) ;
|
||||
cr.set_reference_point(¤t_rp) ;
|
||||
cr.set_reference_point(const_cast<ReferencePoint*>(¤t_rp)) ;
|
||||
|
||||
Stock::store_calibration_request(cr) ;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ using namespace std ;
|
|||
|
||||
|
||||
/**
|
||||
* @param _point The coordinates of the reference point to generate.
|
||||
* @param _cp1 The first capture point (receiver) to use the measurements
|
||||
* of to generate the reference points; it cannot be NULL.
|
||||
* @param _cp2 The second receiver capture point (optional).
|
||||
|
@ -227,7 +228,7 @@ bool AutocalibrationLine::compute_single_packet_ss(pkt_id_t pkt_id)
|
|||
|
||||
|
||||
double AutocalibrationLine::
|
||||
compute_single_ss(pkt_id_t pkt_id, float point_dst)
|
||||
compute_single_ss(const pkt_id_t pkt_id, const float point_dst)
|
||||
{
|
||||
/* Friis index */
|
||||
const string &rx_mac = rx->second.get_mac_addr() ;
|
||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
|||
/// Computes a SS with only one packet in it
|
||||
bool compute_single_packet_ss(pkt_id_t pkt_id) ;
|
||||
/// Actually computes a SS
|
||||
double compute_single_ss(pkt_id_t pkt_id, float point_dst) ;
|
||||
double compute_single_ss(const pkt_id_t pkt_id, const float point_dst) ;
|
||||
|
||||
public:
|
||||
AutocalibrationLine(const Point3D &_point,
|
||||
|
|
|
@ -145,7 +145,7 @@ void AutocalibrationMesh::weight_cps()
|
|||
|
||||
|
||||
void AutocalibrationMesh::init_cp(
|
||||
map<double, pair<double, unordered_map<
|
||||
const map<double, pair<double, unordered_map<
|
||||
string, CapturePoint>::const_iterator> >::const_iterator s)
|
||||
{
|
||||
struct cp ref ;
|
||||
|
@ -266,7 +266,7 @@ bool AutocalibrationMesh::compute_single_packet_ss(pkt_id_t pkt_id)
|
|||
* @returns The weighted SS value in dBm, or 128 in case of error.
|
||||
*/
|
||||
double AutocalibrationMesh::compute_weighted_ss(
|
||||
unsigned int cp_idx, pkt_id_t pkt_id, float point_dst)
|
||||
const unsigned int cp_idx, const pkt_id_t pkt_id, const float point_dst)
|
||||
{
|
||||
const cp &ref = ref_cps[cp_idx] ;
|
||||
const ReferencePoint &rp =
|
||||
|
|
|
@ -57,7 +57,7 @@ protected:
|
|||
|
||||
/// Initialises a struct cp with the values from `s`
|
||||
void init_cp(
|
||||
std::map<double, std::pair<double, std::unordered_map<
|
||||
const std::map<double, std::pair<double, std::unordered_map<
|
||||
std::string, CapturePoint>::const_iterator> >::const_iterator s) ;
|
||||
|
||||
/// Generates the SSs for the current CP
|
||||
|
@ -73,8 +73,9 @@ protected:
|
|||
/// Computes a SS with only one packet in it
|
||||
bool compute_single_packet_ss(pkt_id_t pkt_id) ;
|
||||
/// Computes a SS according to the weight of the CP
|
||||
double compute_weighted_ss(
|
||||
unsigned int cp_idx, pkt_id_t pkt_id, float point_dst) ;
|
||||
double compute_weighted_ss(const unsigned int cp_idx,
|
||||
const pkt_id_t pkt_id,
|
||||
const float point_dst) ;
|
||||
|
||||
public:
|
||||
AutocalibrationMesh(const Point3D &_point): Autocalibration(_point) {}
|
||||
|
|
|
@ -51,10 +51,11 @@ Building::~Building()
|
|||
|
||||
|
||||
/**
|
||||
* @param area A pointer to the Area to add. If it is NULL, nothing
|
||||
* will be added. If the Area it points to already exist in #areas, it is
|
||||
* deleted and nullified, unless it is the same pointer (see the code to
|
||||
* understand!); hmm, maybe we should handle that with exceptions…
|
||||
* @param[in,out] area A pointer to the Area to add. If it is NULL,
|
||||
* nothing will be added. If the Area it points to already exists in
|
||||
* #areas, it is deleted and set to NULL, unless it is the same pointer
|
||||
* (see the code to understand!); hmm, maybe we should handle that with
|
||||
* exceptions…
|
||||
*/
|
||||
void Building::add_area(Area *&area)
|
||||
{
|
||||
|
|
|
@ -46,8 +46,7 @@ public :
|
|||
/** @name Read accessors */
|
||||
//@{
|
||||
const std::string& get_name(void) const ;
|
||||
const std::unordered_map<std::string, Area*>&
|
||||
get_areas(void) const ;
|
||||
const std::unordered_map<std::string, Area*>& get_areas(void) const ;
|
||||
const std::unordered_set<Waypoint*>& get_waypoints(void) const ;
|
||||
//@}
|
||||
|
||||
|
@ -55,9 +54,9 @@ public :
|
|||
//@{
|
||||
void set_name(const std::string &_name) ;
|
||||
/// Adds an Area to the [list of areas](@ref #areas)
|
||||
void add_area(Area *&a) ;
|
||||
void add_area(Area *&area) ;
|
||||
/// Adds a Waypoint to the [list of waypoints](@ref #waypoints)
|
||||
void add_waypoint(const Waypoint *wp) ;
|
||||
void add_waypoint(Waypoint *const wp) ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
@ -110,10 +109,10 @@ inline void Building::set_name(const std::string &_name)
|
|||
* @param wp A pointer to the Waypoint to add. If `wp` is NULL,
|
||||
* nothing will be added.
|
||||
*/
|
||||
inline void Building::add_waypoint(const Waypoint *wp)
|
||||
inline void Building::add_waypoint(Waypoint *const wp)
|
||||
{
|
||||
if (wp != NULL)
|
||||
waypoints.insert(const_cast<Waypoint*>(wp)) ;
|
||||
waypoints.insert(wp) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
/* *** Constructors *** */
|
||||
|
||||
|
||||
CalibrationRequest::
|
||||
CalibrationRequest(uint_fast8_t _type):
|
||||
CalibrationRequest::CalibrationRequest(const uint_fast8_t _type):
|
||||
reference_point(NULL), direction(Direction())
|
||||
{
|
||||
type = _type ;
|
||||
|
@ -29,9 +28,9 @@ CalibrationRequest(uint_fast8_t _type):
|
|||
|
||||
CalibrationRequest::
|
||||
CalibrationRequest(const Request &source,
|
||||
ReferencePoint *_reference_point,
|
||||
ReferencePoint *const _reference_point,
|
||||
const Direction &_direction,
|
||||
uint_fast8_t _type):
|
||||
const uint_fast8_t _type):
|
||||
Request(source), reference_point(_reference_point),
|
||||
direction(_direction)
|
||||
{
|
||||
|
|
|
@ -30,16 +30,16 @@ protected:
|
|||
Direction direction ;
|
||||
|
||||
public:
|
||||
CalibrationRequest(uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ;
|
||||
CalibrationRequest(const uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ;
|
||||
|
||||
CalibrationRequest(const CalibrationRequest &source):
|
||||
Request(source), reference_point(source.reference_point),
|
||||
direction(source.direction) {}
|
||||
|
||||
CalibrationRequest(const Request &source,
|
||||
ReferencePoint *_reference_point = NULL,
|
||||
ReferencePoint *const _reference_point = NULL,
|
||||
const Direction &_direction = Direction(),
|
||||
uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ;
|
||||
const uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ;
|
||||
|
||||
~CalibrationRequest(void) {}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
/** @name Write accessors */
|
||||
//@{
|
||||
void set_direction(const Direction &_direction) ;
|
||||
void set_reference_point(const ReferencePoint *_rp) ;
|
||||
void set_reference_point(ReferencePoint *const _rp) ;
|
||||
/// Adds the CalibrationRequest to the #reference_point list of requests
|
||||
void reference_point_backward_link(void) const ;
|
||||
/// Deletes all the requests of #reference_point
|
||||
|
@ -89,10 +89,10 @@ inline const Direction& CalibrationRequest::get_direction(void) const
|
|||
/* *** Write accessors *** */
|
||||
|
||||
|
||||
inline void CalibrationRequest::set_reference_point(
|
||||
const ReferencePoint *_rp)
|
||||
inline void CalibrationRequest::
|
||||
set_reference_point(ReferencePoint *const _rp)
|
||||
{
|
||||
reference_point = const_cast<ReferencePoint*>(_rp) ;
|
||||
reference_point = _rp ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ public:
|
|||
/** @name Operations */
|
||||
//@{
|
||||
Result compute(const Request &request) ;
|
||||
virtual const ReferencePoint& select_point(
|
||||
const Request &request) = 0 ;
|
||||
virtual const ReferencePoint& select_point(const Request &request) = 0 ;
|
||||
//@}
|
||||
} ;
|
||||
|
||||
|
|
|
@ -85,11 +85,13 @@ void InputMedium::clear_current_request()
|
|||
|
||||
|
||||
/**
|
||||
* The `position` argument can be changed by this function.
|
||||
* The `position` argument can be modified by this function.
|
||||
*/
|
||||
void InputMedium::
|
||||
fill_calibration_request_data(const string &mac_mobile, Point3D &position,
|
||||
const Direction &direction, uint8_t type)
|
||||
fill_calibration_request_data(const string &mac_mobile,
|
||||
Point3D &position,
|
||||
const Direction &direction,
|
||||
const uint8_t type)
|
||||
{
|
||||
// We set the real coordinates (if found) for non-calibration requests
|
||||
if (type != OWL_REQUEST_CALIBRATION &&
|
||||
|
@ -155,8 +157,7 @@ fill_calibration_request_data(const string &mac_mobile, Point3D &position,
|
|||
}
|
||||
|
||||
|
||||
void InputMedium::
|
||||
current_request_to_calibration_request(
|
||||
void InputMedium::current_request_to_calibration_request(
|
||||
const ReferencePoint *const reference_point,
|
||||
const Direction &direction,
|
||||
const uint_fast8_t request_type)
|
||||
|
@ -165,7 +166,8 @@ current_request_to_calibration_request(
|
|||
dynamic_cast<CalibrationRequest*>(current_request) ;
|
||||
if (calibration_request != NULL)
|
||||
{
|
||||
calibration_request->set_reference_point(reference_point) ;
|
||||
calibration_request->set_reference_point(
|
||||
const_cast<ReferencePoint*>(reference_point)) ;
|
||||
calibration_request->set_direction(direction) ;
|
||||
calibration_request->set_type(request_type) ;
|
||||
return ;
|
||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
|||
void fill_calibration_request_data(const std::string &mac_mobile,
|
||||
Point3D &position,
|
||||
const Direction &direction,
|
||||
uint8_t type) ;
|
||||
const uint8_t type) ;
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
void current_request_to_calibration_request(
|
||||
const ReferencePoint *const reference_point,
|
||||
const Direction &direction,
|
||||
uint_fast8_t request_type) ;
|
||||
const uint_fast8_t request_type) ;
|
||||
/// Clears (reallocates to Request if needed) #current_request
|
||||
void clear_current_request(void) ;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ Measurement::~Measurement()
|
|||
* @returns The SS of the packet number `pkt_id.`
|
||||
* @returns 0 if the packet ID does not exist in the SS list.
|
||||
*/
|
||||
ss_t Measurement::get_ss(pkt_id_t pkt_id) const
|
||||
ss_t Measurement::get_ss(const pkt_id_t pkt_id) const
|
||||
{
|
||||
std::map<pkt_id_t, ss_t>::const_iterator ss = ss_list.find(pkt_id) ;
|
||||
if (ss == ss_list.end())
|
||||
|
@ -194,7 +194,7 @@ float Measurement::similarity(const Measurement &source) const
|
|||
|
||||
|
||||
unsigned int Measurement::
|
||||
nb_in_interval(const Measurement &source, float bound) const
|
||||
nb_in_interval(const Measurement &source, const float bound) const
|
||||
{
|
||||
unsigned int nb_values = 0 ;
|
||||
|
||||
|
@ -223,7 +223,7 @@ void Measurement::recalculate_average()
|
|||
}
|
||||
|
||||
|
||||
void Measurement::update_average(ss_t ss_dbm)
|
||||
void Measurement::update_average(const ss_t ss_dbm)
|
||||
{
|
||||
++variance_size ;
|
||||
assert(variance_size <= ss_list.size()) ;
|
||||
|
|
|
@ -29,7 +29,7 @@ class Measurement
|
|||
{
|
||||
protected:
|
||||
/// The CapturePoint that performed the measurement
|
||||
CapturePoint *cp ;
|
||||
const CapturePoint *cp ;
|
||||
/// List of signal strengths captured (in dBm)
|
||||
std::map<pkt_id_t, ss_t> ss_list ;
|
||||
/// Average of all the captured signal strengths (dBm)
|
||||
|
@ -56,17 +56,17 @@ protected:
|
|||
/// Recalculates entirely the average and variance from #ss_list
|
||||
void recalculate_average(void) ;
|
||||
/// Update the average and variance with a new SS
|
||||
void update_average(ss_t ss_dbm) ;
|
||||
void update_average(const ss_t ss_dbm) ;
|
||||
/// Counts the number of SS of source that are within the interval
|
||||
/// [average_dbm-bound;average_dbm+bound]
|
||||
unsigned int nb_in_interval(
|
||||
const Measurement &source, float bound) const ;
|
||||
const Measurement &source, const float bound) const ;
|
||||
//@}
|
||||
|
||||
|
||||
public:
|
||||
Measurement(const CapturePoint *_cp = NULL):
|
||||
cp(const_cast<CapturePoint*>(_cp)), average_dbm(0),
|
||||
Measurement(const CapturePoint *const _cp = NULL):
|
||||
cp(_cp), average_dbm(0),
|
||||
average_mw(0), variance_mw(0), variance_dbm(0),
|
||||
variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {}
|
||||
|
||||
|
@ -81,25 +81,25 @@ public:
|
|||
/** @name Read accessors */
|
||||
//@{
|
||||
/// Returns the CapturePoint associated with the Measurement
|
||||
CapturePoint* get_cp() const ;
|
||||
const CapturePoint* get_cp(void) const ;
|
||||
/// Returns the packet number `pkt_id`
|
||||
ss_t get_ss(pkt_id_t pkt_id) const ;
|
||||
ss_t get_ss(const pkt_id_t pkt_id) const ;
|
||||
/// Returns the mean of the SS list, in dBm
|
||||
float get_average_dbm() const ;
|
||||
float get_average_dbm(void) const ;
|
||||
/// Returns the variance of the SS list
|
||||
float get_variance_mw() const ;
|
||||
float get_variance_mw(void) const ;
|
||||
/// Returns the standard deviation of the SS list (mW)
|
||||
float get_std_deviation_mw() const ;
|
||||
float get_std_deviation_mw(void) const ;
|
||||
/// Returns the standard deviation of the SS list (dBm)
|
||||
float get_std_deviation_dbm() const ;
|
||||
float get_std_deviation_dbm(void) const ;
|
||||
/// Returns the number of SS in the SS list
|
||||
int get_nb_ss() const ;
|
||||
int get_nb_ss(void) const ;
|
||||
//@}
|
||||
|
||||
/** @name Write accessors */
|
||||
//@{
|
||||
/// Associate the Measurement with a CapturePoint
|
||||
void set_cp(const CapturePoint *_cp) ;
|
||||
void set_cp(const CapturePoint *const _cp) ;
|
||||
/// Adds a signal strength (in dBm) to #ss_list
|
||||
void add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) ;
|
||||
/// Adds several signal strengths (in dBm) to #ss_list
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
/* *** Read accessors *** */
|
||||
|
||||
|
||||
inline CapturePoint* Measurement::get_cp() const
|
||||
inline const CapturePoint* Measurement::get_cp() const
|
||||
{
|
||||
return cp ;
|
||||
}
|
||||
|
@ -187,9 +187,9 @@ inline int Measurement::get_nb_ss() const
|
|||
/* *** Write accessors *** */
|
||||
|
||||
|
||||
inline void Measurement::set_cp(const CapturePoint *_cp)
|
||||
inline void Measurement::set_cp(const CapturePoint *const _cp)
|
||||
{
|
||||
cp = const_cast<CapturePoint*>(_cp) ;
|
||||
cp = _cp ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ using namespace std ;
|
|||
|
||||
|
||||
Point3D MinMax::trilaterate(
|
||||
const unordered_map<CapturePoint*, float> &_cp_distances)
|
||||
const unordered_map<const CapturePoint*, float> &_cp_distances)
|
||||
{
|
||||
min = INFINITE ;
|
||||
centre = start ;
|
||||
|
@ -36,7 +36,7 @@ Point3D MinMax::trilaterate(
|
|||
|
||||
|
||||
Point3D MinMax::trilaterate_2d(
|
||||
const unordered_map<CapturePoint*, float> &_cp_distances, float z)
|
||||
const unordered_map<const CapturePoint*, float> &_cp_distances, float z)
|
||||
{
|
||||
min = INFINITE ;
|
||||
centre = start ;
|
||||
|
@ -50,11 +50,10 @@ Point3D MinMax::trilaterate_2d(
|
|||
}
|
||||
|
||||
|
||||
void MinMax::iterate(float x, float y, float z)
|
||||
void MinMax::iterate(const float x, const float y, const float z)
|
||||
{
|
||||
float d_max = 0 ;
|
||||
for (unordered_map<CapturePoint*, float>::const_iterator i =
|
||||
cp_distances->begin() ; i != cp_distances->end() ; ++i)
|
||||
for (auto i = cp_distances->begin() ; i != cp_distances->end() ; ++i)
|
||||
{
|
||||
float dist =
|
||||
Point3D(x, y, z).distance_to_sphere(
|
||||
|
|
|
@ -23,9 +23,9 @@ class MinMax: public TrilaterationMethod
|
|||
private:
|
||||
float min ;
|
||||
Point3D centre ;
|
||||
std::unordered_map<CapturePoint*, float> const *cp_distances ;
|
||||
std::unordered_map<const CapturePoint*, float> const *cp_distances ;
|
||||
|
||||
void iterate(float x, float y, float z) ;
|
||||
void iterate(const float x, const float y, const float z) ;
|
||||
|
||||
protected:
|
||||
const Point3D start ;
|
||||
|
@ -45,9 +45,9 @@ public:
|
|||
~MinMax(void) {}
|
||||
|
||||
Point3D trilaterate(
|
||||
const std::unordered_map<CapturePoint*, float> &_cp_distances) ;
|
||||
const std::unordered_map<const CapturePoint*, float> &_cp_distances) ;
|
||||
Point3D trilaterate_2d(
|
||||
const std::unordered_map<CapturePoint*, float> &_cp_distances,
|
||||
const std::unordered_map<const CapturePoint*, float> &_cp_distances,
|
||||
float z) ;
|
||||
} ;
|
||||
|
||||
|
|
|
@ -35,10 +35,4 @@ public:
|
|||
void write(const ResultList &results) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Operations *** */
|
||||
|
||||
|
||||
|
||||
#endif // _OWLPS_POSITIONING_OUTPUTCSV_HH_
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
/// Returns the degree value of `radians`
|
||||
static double rad2deg(const double &radians) ;
|
||||
/// Checks if `value` is in the interval [center-width;center+width]
|
||||
static bool is_in_interval(float center, float bound, float value) ;
|
||||
static bool is_in_interval(const float center, const float bound,
|
||||
const float value) ;
|
||||
//@}
|
||||
|
||||
/** @name Measurements */
|
||||
|
@ -98,7 +99,7 @@ hash_combine(std::size_t &seed, const T &v)
|
|||
* @returns `false` if value does not belong to the interval.
|
||||
*/
|
||||
inline bool PosUtil::
|
||||
is_in_interval(float center, float bound, float value)
|
||||
is_in_interval(const float center, const float bound, const float value)
|
||||
{
|
||||
if (bound == 0)
|
||||
return value == center ;
|
||||
|
|
|
@ -124,7 +124,7 @@ get_requests(const string &mac_transmitter) const
|
|||
/* *** Write accessors *** */
|
||||
|
||||
|
||||
void ReferencePoint::delete_request(const CalibrationRequest *r)
|
||||
void ReferencePoint::delete_request(const CalibrationRequest *const r)
|
||||
{
|
||||
for (vector<CalibrationRequest*>::iterator i = requests.begin() ;
|
||||
i != requests.end() ; ++i)
|
||||
|
@ -255,9 +255,9 @@ friis_index_for_cp(const string &cp_mac) const
|
|||
* ReferencePoint. To obtain the real (averaged) Friis index, one
|
||||
* has to divide the returned sum by the number of indexes.
|
||||
*
|
||||
* @param cp The CapturePoint to work on.
|
||||
* @param const_term The "constant" part of the computation.
|
||||
* @param nb_indexes (result) The number of indexes computed.
|
||||
* @param[in] cp The CapturePoint to work on.
|
||||
* @param[in] const_term The "constant" part of the computation.
|
||||
* @param[out] nb_indexes The number of indexes computed.
|
||||
*
|
||||
* @returns The sum of all Friis indexes for the CapturePoint.
|
||||
* @returns 0 if the CP is unknown at this ReferencePoint.
|
||||
|
@ -319,7 +319,7 @@ float ReferencePoint::friis_indexes_for_cp(
|
|||
* is no packet with the wanted ID.
|
||||
*/
|
||||
float ReferencePoint::
|
||||
friis_index_for_cp(const string &cp_mac, pkt_id_t pkt_id) const
|
||||
friis_index_for_cp(const string &cp_mac, const pkt_id_t pkt_id) const
|
||||
{
|
||||
const CapturePoint &cp = Stock::get_cp(cp_mac) ;
|
||||
double const_term = cp.friis_constant_term() ;
|
||||
|
|
|
@ -70,9 +70,9 @@ public:
|
|||
/** @name Write accessors */
|
||||
//@{
|
||||
/// Adds a Request to the [requests' list](@ref #requests)
|
||||
void add_request(const CalibrationRequest *r) ;
|
||||
void add_request(const CalibrationRequest *const r) ;
|
||||
/// Deletes a Request from the [requests' list](@ref #requests)
|
||||
void delete_request(const CalibrationRequest *r) ;
|
||||
void delete_request(const CalibrationRequest *const r) ;
|
||||
/// Deletes all the requests contained in #requests
|
||||
void delete_requests(void) ;
|
||||
/// Deletes the requests that are not sent by a CP
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
int &nb_indexes) const ;
|
||||
/// Computes the Friis index for the given CapturePoint and packet ID
|
||||
float friis_index_for_cp(
|
||||
const std::string &cp_mac, pkt_id_t pkt_id) const ;
|
||||
const std::string &cp_mac, const pkt_id_t pkt_id) const ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
|
|
@ -31,7 +31,7 @@ Request::Request(
|
|||
const unordered_map<string, Measurement> &_measurements
|
||||
):
|
||||
type(OWL_REQUEST_UNDEFINED), nb_packets(1),
|
||||
mobile(const_cast<Mobile*>(_mobile)), time_sent(_time_sent),
|
||||
mobile(_mobile), time_sent(_time_sent),
|
||||
measurements(_measurements), real_position(NULL)
|
||||
{
|
||||
received_now() ;
|
||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
|||
/// Number of packets sent by the mobile for this request
|
||||
pkt_id_t nb_packets ;
|
||||
/// The mobile that sent the request
|
||||
Mobile *mobile ;
|
||||
const Mobile *mobile ;
|
||||
/// Local date of the request on the mobile
|
||||
Timestamp time_sent ;
|
||||
/// Date at which we received the request from the aggregator
|
||||
|
@ -66,7 +66,7 @@ protected:
|
|||
typedef std::unordered_map<std::string, Measurement> measurements_list ;
|
||||
|
||||
public:
|
||||
Request(const Mobile *_mobile = NULL,
|
||||
Request(const Mobile *const _mobile = NULL,
|
||||
const Timestamp &_time_sent = Timestamp(),
|
||||
const std::unordered_map<std::string, Measurement>
|
||||
&_measurements = measurements_list()) ;
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
//@{
|
||||
uint_fast8_t get_type(void) const ;
|
||||
uint_fast16_t get_nb_packets(void) const ;
|
||||
Mobile* get_mobile(void) const ;
|
||||
const Mobile* get_mobile(void) const ;
|
||||
const Timestamp& get_time_sent(void) const ;
|
||||
const Timestamp& get_time_received(void) const ;
|
||||
/// Returns all the measurements
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
//@{
|
||||
void set_type(const uint_fast8_t _type) ;
|
||||
void set_nb_packets(const uint_fast16_t _nb_packets) ;
|
||||
void set_mobile(const Mobile *_mobile) ;
|
||||
void set_mobile(const Mobile *const _mobile) ;
|
||||
void set_time_sent(const Timestamp &_time_sent) ;
|
||||
void received_now(void) ;
|
||||
void set_measurements(const std::unordered_map
|
||||
|
@ -154,7 +154,7 @@ inline uint_fast16_t Request::get_nb_packets() const
|
|||
}
|
||||
|
||||
|
||||
inline Mobile* Request::get_mobile() const
|
||||
inline const Mobile* Request::get_mobile() const
|
||||
{
|
||||
return mobile ;
|
||||
}
|
||||
|
@ -201,9 +201,9 @@ inline void Request::set_nb_packets(const uint_fast16_t _nb_packets)
|
|||
}
|
||||
|
||||
|
||||
inline void Request::set_mobile(const Mobile *_mobile)
|
||||
inline void Request::set_mobile(const Mobile *const _mobile)
|
||||
{
|
||||
mobile = const_cast<Mobile*>(_mobile) ;
|
||||
mobile = _mobile ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ using namespace std ;
|
|||
* The error (distance between _position and _real_position) is
|
||||
* computed automatically.
|
||||
*/
|
||||
Result::Result(const Request *_request,
|
||||
Result::Result(const Request *const _request,
|
||||
const std::string &_algorithm,
|
||||
const Point3D &_position,
|
||||
const Point3D &real_position):
|
||||
|
|
|
@ -36,14 +36,14 @@ protected:
|
|||
float error ;
|
||||
|
||||
public:
|
||||
Result(const Request *_request = NULL,
|
||||
Result(const Request *const _request = NULL,
|
||||
const std::string &_algorithm = "UnknownAlgorithm"):
|
||||
request(_request), algorithm(_algorithm), error(-1) {}
|
||||
Result(const Request *_request, const std::string &_algorithm,
|
||||
Result(const Request *const _request, const std::string &_algorithm,
|
||||
const Point3D &_position):
|
||||
request(_request), algorithm(_algorithm), position(_position),
|
||||
error(-1) {}
|
||||
Result(const Request *_request, const std::string &_algorithm,
|
||||
Result(const Request *const _request, const std::string &_algorithm,
|
||||
const Point3D &_position, const Point3D &real_position) ;
|
||||
~Result(void) {}
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ class Request ;
|
|||
class ResultList
|
||||
{
|
||||
protected:
|
||||
Request *request ;
|
||||
const Request *request ;
|
||||
std::vector<Result> results ;
|
||||
|
||||
public:
|
||||
ResultList(const Request *_request = NULL,
|
||||
ResultList(const Request *const _request = NULL,
|
||||
const std::vector<Result> &_results = std::vector<Result>()):
|
||||
request(const_cast<Request*>(_request)), results(_results) {}
|
||||
request(_request), results(_results) {}
|
||||
ResultList(const ResultList &source):
|
||||
request(source.request), results(source.results) {}
|
||||
~ResultList(void) ;
|
||||
|
|
|
@ -133,7 +133,7 @@ find_create_waypoint(const Point3D &point)
|
|||
|
||||
|
||||
void Stock::waypoint_remove_building(const Waypoint &point,
|
||||
const Building *building)
|
||||
Building *const building)
|
||||
{
|
||||
unordered_map<Point3D, Waypoint>::iterator i =
|
||||
waypoints.find(point) ;
|
||||
|
@ -721,7 +721,7 @@ delete_calibration_request(const CalibrationRequest &request)
|
|||
/**
|
||||
* @param timeout The maximum age of the calibration requests (seconds).
|
||||
*/
|
||||
void Stock::delete_calibration_requests_older_than(int timeout)
|
||||
void Stock::delete_calibration_requests_older_than(const int timeout)
|
||||
{
|
||||
assert(timeout > 0) ;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
/// Deletes a Building from the building list of a Waypoint; deletes
|
||||
/// the Waypoint if it is not linked to any Building any more
|
||||
static void waypoint_remove_building(const Waypoint &point,
|
||||
const Building *building) ;
|
||||
Building *const building) ;
|
||||
//@}
|
||||
|
||||
/** @name Mobile operations */
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
const CalibrationRequest &request) ;
|
||||
/// Deletes the calibration requests that are older than `timeout`
|
||||
/// seconds
|
||||
static void delete_calibration_requests_older_than(int timeout) ;
|
||||
static void delete_calibration_requests_older_than(const int timeout) ;
|
||||
/// Searches for a CalibrationRequest and adds it if it does not exist
|
||||
static const CalibrationRequest&
|
||||
find_create_calibration_request(const CalibrationRequest &request) ;
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
Stock::find_create_waypoint(Waypoint(&b2, 43,45,909)) ;
|
||||
const Waypoint &wp2 =
|
||||
Stock::find_create_waypoint(Waypoint(&b2, 12,78,2)) ;
|
||||
b2.add_waypoint(&wp1) ;
|
||||
b2.add_waypoint(&wp2) ;
|
||||
b2.add_waypoint(const_cast<Waypoint*>(&wp1)) ;
|
||||
b2.add_waypoint(const_cast<Waypoint*>(&wp2)) ;
|
||||
waypoints1.insert(const_cast<Waypoint*>(&wp1)) ;
|
||||
waypoints1.insert(const_cast<Waypoint*>(&wp2)) ;
|
||||
TS_ASSERT_EQUALS(b2.get_waypoints(), waypoints1) ;
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
ap2(Point3D(10,0,0)),
|
||||
ap3(Point3D(0,10,0)),
|
||||
ap4(Point3D(5,5,4)) ;
|
||||
std::unordered_map<CapturePoint*, float> ap_distances ;
|
||||
std::unordered_map<const CapturePoint*, float> ap_distances ;
|
||||
ap_distances[&ap1] = 7.071 ;
|
||||
ap_distances[&ap2] = 7.071 ;
|
||||
ap_distances[&ap3] = 7.071 ;
|
||||
|
|
|
@ -53,13 +53,14 @@ public:
|
|||
{
|
||||
Point3D coordinates(42,21,98) ;
|
||||
const Building &building = Stock::find_create_building("Build") ;
|
||||
Waypoint wp1(&building, coordinates) ;
|
||||
Waypoint wp1(const_cast<Building*>(&building), coordinates) ;
|
||||
const Waypoint
|
||||
&wp1_ref1 = Stock::find_create_waypoint(wp1),
|
||||
&wp1_ref2 = Stock::find_create_waypoint(coordinates) ;
|
||||
TS_ASSERT_EQUALS(&wp1_ref1, &wp1_ref2) ;
|
||||
|
||||
Stock::waypoint_remove_building(wp1_ref1, &building) ;
|
||||
Stock::waypoint_remove_building(wp1_ref1,
|
||||
const_cast<Building*>(&building)) ;
|
||||
// TODO: test if the waypoint was removed (needs a function
|
||||
// Stock::get_waypoint()).
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ TextFileReader::~TextFileReader()
|
|||
* Tabs and spaces at the begining of a line are deleted.
|
||||
* If the first non-blank character of a line is a #, then the line is
|
||||
* skipped (note that comments at the end of a line are *not* handled).
|
||||
* @param text Output argument; unchanged in case of error.
|
||||
* @param[out] text Output argument; unchanged in case of error.
|
||||
* @returns `false` in case of error, `true` else.
|
||||
*/
|
||||
bool TextFileReader::read_nonblank_line(string &text)
|
||||
|
@ -85,7 +85,8 @@ bool TextFileReader::read_nonblank_line(string &text)
|
|||
|
||||
|
||||
/**
|
||||
* @returns The string read, or an empty string in case of error.
|
||||
* @param[out] text The string read.
|
||||
* @returns `true` in case of success, `false` in case of error.
|
||||
*/
|
||||
bool TextFileReader::read_line(string &text)
|
||||
{
|
||||
|
|
|
@ -24,15 +24,15 @@ class TrilaterationAlgorithm: public virtual PositioningAlgorithm
|
|||
protected:
|
||||
const Request *request ;
|
||||
|
||||
std::unordered_map<CapturePoint*, float> cp_distances ;
|
||||
std::unordered_map<const CapturePoint*, float> cp_distances ;
|
||||
TrilaterationMethod *trilateration_method ;
|
||||
|
||||
/** @name Operations */
|
||||
//@{
|
||||
double make_constant_term(const Measurement &measurement) ;
|
||||
void compute_cp_distance_circles() ;
|
||||
Point3D trilaterate() ;
|
||||
Point3D trilaterate_2d(float z) ;
|
||||
void compute_cp_distance_circles(void) ;
|
||||
Point3D trilaterate(void) ;
|
||||
Point3D trilaterate_2d(const float z) ;
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,7 @@ inline Point3D TrilaterationAlgorithm::trilaterate()
|
|||
}
|
||||
|
||||
|
||||
inline Point3D TrilaterationAlgorithm::trilaterate_2d(float z)
|
||||
inline Point3D TrilaterationAlgorithm::trilaterate_2d(const float z)
|
||||
{
|
||||
return trilateration_method->trilaterate_2d(cp_distances, z) ;
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ public:
|
|||
|
||||
/// Selects a point in 3D space
|
||||
virtual Point3D trilaterate(
|
||||
const std::unordered_map<CapturePoint*, float> &cp_distances) = 0 ;
|
||||
const std::unordered_map<const CapturePoint*, float> &cp_distances) = 0 ;
|
||||
|
||||
/// Selects a point in 2D space, given its vertical coordinate (z)
|
||||
virtual Point3D trilaterate_2d(
|
||||
const std::unordered_map<CapturePoint*, float> &cp_distances,
|
||||
float z) = 0 ;
|
||||
const std::unordered_map<const CapturePoint*, float> &cp_distances,
|
||||
const float z) = 0 ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_
|
||||
|
|
|
@ -54,7 +54,8 @@ namespace po = boost::program_options ;
|
|||
* @param argc Number of arguments passed to the program.
|
||||
* @param argv Values of the arguments.
|
||||
*/
|
||||
UserInterface::UserInterface(const int argc, const char **const argv):
|
||||
UserInterface::UserInterface(const int argc,
|
||||
const char *const *const argv):
|
||||
cli_argument_count(argc), cli_argument_values(argv)
|
||||
{
|
||||
assert(cli_argument_values) ;
|
||||
|
|
|
@ -23,7 +23,7 @@ class UserInterface
|
|||
{
|
||||
protected:
|
||||
const int cli_argument_count ;
|
||||
const char **const cli_argument_values ;
|
||||
const char *const *const cli_argument_values ;
|
||||
boost::program_options::options_description *cli_options ;
|
||||
boost::program_options::options_description *file_options ;
|
||||
|
||||
|
@ -55,7 +55,7 @@ protected:
|
|||
//@}
|
||||
|
||||
public:
|
||||
UserInterface(const int argc, const char **const argv) ;
|
||||
UserInterface(const int argc, const char *const *const argv) ;
|
||||
|
||||
~UserInterface(void) ;
|
||||
} ;
|
||||
|
|
|
@ -31,12 +31,12 @@ using namespace std ;
|
|||
* @param _y Y coordinate.
|
||||
* @param _z Z coordinate.
|
||||
*/
|
||||
Waypoint::Waypoint(const Building *_b,
|
||||
Waypoint::Waypoint(Building *const _b,
|
||||
const float &_x, const float &_y, const float &_z
|
||||
): Point3D(_x, _y, _z)
|
||||
{
|
||||
if (_b != NULL)
|
||||
buildings.insert(const_cast<Building*>(_b)) ;
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,10 +45,10 @@ Waypoint::Waypoint(const Building *_b,
|
|||
* If it is NULL, #buildings will remain empty.
|
||||
* @param p Coordinates of the Waypoint.
|
||||
*/
|
||||
Waypoint::Waypoint(const Building *_b, const Point3D &p): Point3D(p)
|
||||
Waypoint::Waypoint(Building *const _b, const Point3D &p): Point3D(p)
|
||||
{
|
||||
if (_b != NULL)
|
||||
buildings.insert(const_cast<Building*>(_b)) ;
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ protected:
|
|||
std::unordered_set<Building*> buildings ;
|
||||
|
||||
public:
|
||||
Waypoint(const Building *_b = NULL, const float &_x = 0,
|
||||
Waypoint(Building *const _b = NULL, const float &_x = 0,
|
||||
const float &_y = 0, const float &_z = 0) ;
|
||||
|
||||
Waypoint(const Building *_b, const Point3D &p) ;
|
||||
Waypoint(Building *const _b, const Point3D &p) ;
|
||||
|
||||
Waypoint(const Point3D &p): Point3D(p) {}
|
||||
|
||||
|
@ -58,11 +58,11 @@ public:
|
|||
/** @name Write accessors */
|
||||
//@{
|
||||
/// Adds a Building to the [buildings' list](@ref #buildings)
|
||||
void add_building(const Building *_b) ;
|
||||
void add_building(Building *const _b) ;
|
||||
/// Adds the Building list of `source` to #buildings
|
||||
void add_buildings(const Waypoint &source) ;
|
||||
/// Removes a Building from #buildings
|
||||
void remove_building(const Building *_b) ;
|
||||
void remove_building(Building *const _b) ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
@ -113,17 +113,10 @@ Waypoint::get_buildings() const
|
|||
* the Waypoint destruction (do *not* pass a pointer to a local
|
||||
* variable!).
|
||||
*/
|
||||
inline void Waypoint::add_building(const Building *_b)
|
||||
inline void Waypoint::add_building(Building *const _b)
|
||||
{
|
||||
if (_b != NULL)
|
||||
buildings.insert(const_cast<Building*>(_b)) ;
|
||||
}
|
||||
|
||||
|
||||
inline void Waypoint::remove_building(const Building *_b)
|
||||
{
|
||||
if (_b != NULL)
|
||||
buildings.erase(const_cast<Building*>(_b)) ;
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,6 +126,13 @@ inline void Waypoint::add_buildings(const Waypoint &source)
|
|||
}
|
||||
|
||||
|
||||
inline void Waypoint::remove_building(Building *const _b)
|
||||
{
|
||||
if (_b != NULL)
|
||||
buildings.erase(_b) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operators *** */
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ public:
|
|||
//@{
|
||||
void set_ip_addr(const std::string &_ip_addr) ;
|
||||
void set_mac_addr(const std::string &_mac_addr) ;
|
||||
void set_antenna_gain(float _antenna_gain) ;
|
||||
void set_trx_power(float _trx_power) ;
|
||||
void set_antenna_gain(const float _antenna_gain) ;
|
||||
void set_trx_power(const float _trx_power) ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
@ -140,13 +140,13 @@ inline void WifiDevice::set_mac_addr(const std::string &_mac_addr)
|
|||
}
|
||||
|
||||
|
||||
inline void WifiDevice::set_antenna_gain(float _antenna_gain)
|
||||
inline void WifiDevice::set_antenna_gain(const float _antenna_gain)
|
||||
{
|
||||
antenna_gain = _antenna_gain ;
|
||||
}
|
||||
|
||||
|
||||
inline void WifiDevice::set_trx_power(float _trx_power)
|
||||
inline void WifiDevice::set_trx_power(const float _trx_power)
|
||||
{
|
||||
trx_power = _trx_power ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue