132 lines
2.7 KiB
C++
132 lines
2.7 KiB
C++
#ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_
|
|
#define _OWLPS_POSITIONING_MEASUREMENT_HH_
|
|
|
|
#include "accesspoint.hh"
|
|
|
|
#include <vector>
|
|
#include <ostream>
|
|
#include <cmath>
|
|
|
|
/// Represents a list of signal strengths captured by one AccessPoint
|
|
class Measurement
|
|
{
|
|
protected:
|
|
/// The AccessPoint that performed the measurement
|
|
AccessPoint *ap ;
|
|
/// List of signal strengths captured
|
|
std::vector<int> ss_list ;
|
|
/// Average of all signal strength captured
|
|
float average_ss ;
|
|
|
|
/// Recalculates #average_ss from #ss_list
|
|
void update_average_ss(void) ;
|
|
|
|
public:
|
|
/// \brief Constructs a Measurement from an AccessPoint and a list
|
|
/// of signal strengths (or default constructor)
|
|
Measurement(const AccessPoint *_ap = NULL,
|
|
const std::vector<int> &_ss_list = std::vector<int>()) ;
|
|
/// Copy constructor
|
|
Measurement(const Measurement &m) ;
|
|
|
|
~Measurement(void) ; ///< Destructor
|
|
|
|
/** @name Read accessors */
|
|
//@{
|
|
/// #ap read accessor
|
|
AccessPoint* get_ap() const ;
|
|
/// #ss_list read accessor
|
|
const std::vector<int>& get_ss_list() const ;
|
|
/// #average_ss read accessor
|
|
float get_average_ss() const ;
|
|
//float get_ss_square_distance(const float &ss) const ;
|
|
//@}
|
|
|
|
/** @name Write accessors */
|
|
//@{
|
|
/// #ap write accessor
|
|
void set_ap(const AccessPoint *_ap) ;
|
|
/// Adds a signal strength to #ss_list
|
|
void add_ss(const int &ss) ;
|
|
/// #ss_list write accessor
|
|
void set_ss_list(const std::vector<int> &_ss_list) ;
|
|
/// Reinitialises the Measurement
|
|
void clear(void) ;
|
|
//@}
|
|
|
|
/** @name Operators */
|
|
//@{
|
|
const Measurement& operator=(const Measurement &m) ;
|
|
bool operator==(const Measurement &m) const ;
|
|
bool operator!=(const Measurement &m) const ;
|
|
operator bool(void) const ; ///< Cast to bool operator
|
|
//@}
|
|
|
|
/// Displays a Measurement
|
|
friend std::ostream &operator<<(std::ostream &os, const Measurement &m) ;
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
inline AccessPoint* Measurement::get_ap() const
|
|
{
|
|
return ap ;
|
|
}
|
|
|
|
|
|
inline const std::vector<int>& Measurement::get_ss_list() const
|
|
{
|
|
return ss_list ;
|
|
}
|
|
|
|
|
|
inline float Measurement::get_average_ss() const
|
|
{
|
|
return average_ss ;
|
|
}
|
|
|
|
|
|
// inline float Measurement::get_ss_square_distance(const float &ss) const
|
|
// {
|
|
// return ((ss - average_ss) * (ss - average_ss)) ;
|
|
// }
|
|
|
|
|
|
|
|
/* *** write accessors *** */
|
|
|
|
|
|
inline void Measurement::set_ap(const AccessPoint *_ap)
|
|
{
|
|
ap = (AccessPoint *) _ap ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Operators *** */
|
|
|
|
|
|
inline bool Measurement::operator!=(const Measurement &m) const
|
|
{
|
|
return !(*this == m) ;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return \em false if the Measurement is empty.
|
|
* @return \em true if at least one attribute is initialised.
|
|
*/
|
|
inline Measurement::operator bool() const
|
|
{
|
|
return
|
|
ap != NULL ||
|
|
ss_list.size() > 0 ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_MEASUREMENT_HH_
|