owlps/owlps-positioning/src/referencepoint.hh

152 lines
4.0 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comté
* (Université de Franche-Comté), France.
*/
#ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_
#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_
class AccessPoint ;
class CalibrationRequest ;
class Request ;
class Measurement ;
#include "point3d.hh"
#include <vector>
#include <ostream>
#include <boost/tr1/unordered_map.hpp>
/// Represents a reference point in 3-D space
class ReferencePoint: public Point3D
{
protected:
/// List of CalibrationRequest associated with the ReferencePoint
/** Note that \em requests is a \em pointer list: only pointers
are stored, not values. */
std::vector<CalibrationRequest*> requests ;
/** @name Read accessors */
//@{
std::tr1::unordered_map<std::string, Measurement>
get_all_measurements(void) const ;
/// Returns all the measurements sent by the given mobile
std::tr1::unordered_map<std::string, Measurement>
get_all_measurements(const std::string &mac_transmitter) const ;
/// Returns the calibration requests sent by the given mobile
const std::vector<CalibrationRequest*> get_requests(
const std::string &mac_transmitter) const ;
//@}
public:
ReferencePoint(const float &_x = 0,
const float &_y = 0,
const float &_z = 0): Point3D(_x, _y, _z) {}
ReferencePoint(const Point3D &p): Point3D(p) {}
ReferencePoint(const ReferencePoint &source):
Point3D(source), requests(source.requests) {}
~ReferencePoint(void) ;
/** @name Read accessors */
//@{
const std::vector<CalibrationRequest*>& get_requests(void) const ;
double average_measurements(const std::string &mac_transmitter) const ;
//@}
/** @name Write accessors */
//@{
/// Adds a Request to the \link #requests request list\endlink
void add_request(const CalibrationRequest *r) ;
/// Deletes all the requests contained in #requests
void delete_requests(void) ;
/// Deletes the requests that are not sent by an AP
bool delete_generated_requests(void) ;
//@}
/** @name Operations */
//@{
/// Computes the distance between the ReferencePoint and a Request
float ss_square_distance(const Request &source) const ;
/// Computes the Friis index for the given AccessPoint
float friis_index_for_ap(const std::string &ap_mac) const ;
/// Computes the Friis indexes sum for the given AccessPoint
float friis_indexes_for_ap(
const AccessPoint &ap, const double &const_term,
int &nb_indexes) const ;
//@}
/** @name Operators */
//@{
ReferencePoint& operator=(const ReferencePoint &source) ;
bool operator==(const ReferencePoint &source) const ;
bool operator!=(const ReferencePoint &source) const ;
//@}
/// Displays a ReferencePoint
friend std::ostream &operator<<(std::ostream &os, const ReferencePoint &rp) ;
/// Hashes a ReferencePoint
friend std::size_t hash_value(const ReferencePoint &source) ;
} ;
/* *** Read accessors *** */
inline const
std::vector<CalibrationRequest*>& ReferencePoint::get_requests() const
{
return requests ;
}
/* *** Write accessors *** */
/**
* @param r A pointer to the CalibrationRequest to add. If it is
* NULL, nothing will be done.
* The memory pointed by this pointer must not be deallocated before
* the ReferencePoint destruction (do \em not pass a pointer to a local
* variable!).
*/
inline void ReferencePoint::add_request(const CalibrationRequest *r)
{
if (r != NULL)
requests.push_back(const_cast<CalibrationRequest*>(r)) ;
}
/* *** Operators *** */
inline bool ReferencePoint::operator!=(const ReferencePoint &source) const
{
return !(*this == source) ;
}
struct reference_point_equal_to:
public std::binary_function<ReferencePoint, ReferencePoint, bool>
{
bool operator()(const ReferencePoint &source1,
const ReferencePoint &source2) const
{
return
static_cast<Point3D>(source1) == static_cast<Point3D>(source2) ;
}
} ;
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_