2010-01-12 00:31:22 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_STOCK_HH_
|
|
|
|
#define _OWLPS_POSITIONING_STOCK_HH_
|
|
|
|
|
2010-04-02 14:03:55 +02:00
|
|
|
#include "building.hh"
|
2010-04-13 10:47:10 +02:00
|
|
|
#include "waypoint.hh"
|
2010-01-12 00:31:22 +01:00
|
|
|
#include "mobile.hh"
|
|
|
|
#include "accesspoint.hh"
|
2010-02-19 11:42:04 +01:00
|
|
|
#include "referencepoint.hh"
|
|
|
|
#include "calibrationrequest.hh"
|
2010-01-12 00:31:22 +01:00
|
|
|
|
2010-02-01 17:36:45 +01:00
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
2010-02-19 11:42:04 +01:00
|
|
|
#include <boost/tr1/unordered_set.hpp>
|
2010-01-12 00:31:22 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Storage class
|
2010-01-12 00:31:22 +01:00
|
|
|
class Stock
|
|
|
|
{
|
|
|
|
private:
|
2010-04-02 14:03:55 +02:00
|
|
|
/// List of known Building
|
2010-06-21 14:54:50 +02:00
|
|
|
/** The string key of the map is the Building name. */
|
2010-04-02 14:03:55 +02:00
|
|
|
static std::tr1::unordered_map<std::string, Building> buildings ;
|
|
|
|
|
2010-04-13 10:47:10 +02:00
|
|
|
/// List of known Waypoint
|
|
|
|
static std::tr1::unordered_map<Point3D, Waypoint> waypoints ;
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// List of known Mobile
|
2010-06-21 14:54:50 +02:00
|
|
|
/** The string key of the map is the Mobile MAC address. */
|
2010-01-12 00:31:22 +01:00
|
|
|
static std::tr1::unordered_map<std::string, Mobile> mobiles ;
|
2010-01-16 12:23:07 +01:00
|
|
|
|
|
|
|
/// List of known AccessPoint
|
2010-06-21 14:54:50 +02:00
|
|
|
/** The string key of the map is the AccessPoint MAC address. */
|
2010-01-12 00:31:22 +01:00
|
|
|
static std::tr1::unordered_map<std::string, AccessPoint> aps ;
|
|
|
|
|
2010-02-19 11:42:04 +01:00
|
|
|
/// List of known ReferencePoint
|
2011-06-07 14:08:34 +02:00
|
|
|
static std::tr1::unordered_set
|
|
|
|
<ReferencePoint, boost::hash<ReferencePoint>, reference_point_equal_to>
|
|
|
|
reference_points ;
|
2010-02-19 11:42:04 +01:00
|
|
|
|
|
|
|
/// List of known CalibrationRequest
|
|
|
|
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
|
|
|
|
|
2010-01-12 00:31:22 +01:00
|
|
|
public:
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name Building operations */
|
|
|
|
//@{
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Returns the number of buildings
|
2011-06-16 14:10:43 +02:00
|
|
|
static unsigned int nb_buildings(void) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Reads the Building corresponding to a given name
|
2010-04-02 14:03:55 +02:00
|
|
|
static const Building& get_building(const std::string &name) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Searches for a Building and creates it if it does not exist
|
2010-04-02 14:03:55 +02:00
|
|
|
static const Building& find_create_building(const std::string &name) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-04-02 14:03:55 +02:00
|
|
|
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name Waypoint operations */
|
|
|
|
//@{
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Returns the number of waypoints
|
2011-06-16 14:10:43 +02:00
|
|
|
static unsigned int nb_waypoints(void) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Searches for a Waypoint and adds it if it does not exist
|
2010-04-13 10:47:10 +02:00
|
|
|
static const Waypoint&
|
|
|
|
find_create_waypoint(const Waypoint &point) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Searches for a Waypoint from its coordinates and adds it
|
|
|
|
/// if it does not exist
|
2010-04-13 10:47:10 +02:00
|
|
|
static const Waypoint&
|
|
|
|
find_create_waypoint(const Point3D &point) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Deletes a Building from the building list of a Waypoint;
|
|
|
|
/// deletes the Waypoint if it is not linked to any Building any more
|
2010-04-13 10:47:10 +02:00
|
|
|
static void waypoint_remove_building(const Waypoint &point,
|
|
|
|
const Building *building) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-04-13 10:47:10 +02:00
|
|
|
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name Mobile operations */
|
|
|
|
//@{
|
2011-07-19 18:43:54 +02:00
|
|
|
/// Returns the number of mobiles
|
|
|
|
static unsigned int nb_mobiles(void) ;
|
2011-07-19 19:08:50 +02:00
|
|
|
/// Verify the existence of a mobile
|
|
|
|
static bool mobile_exists(const std::string &mac) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Reads the Mobile corresponding to a given MAC address
|
2010-01-12 00:31:22 +01:00
|
|
|
static const Mobile& get_mobile(const std::string &mac) ;
|
2011-07-19 18:20:20 +02:00
|
|
|
/// \brief Searches for a Mobile given its MAC address and creates
|
|
|
|
/// it if it does not exist
|
2010-04-01 11:03:24 +02:00
|
|
|
static const Mobile& find_create_mobile(const std::string &mac) ;
|
2011-07-19 18:20:20 +02:00
|
|
|
/// Searches for a Mobile and create it if it does not exist
|
|
|
|
static const Mobile& find_create_mobile(const Mobile &source) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Returns a reference to the Mobile corresponding to a
|
|
|
|
/// given MAC address
|
2010-01-12 00:31:22 +01:00
|
|
|
static Mobile& getw_mobile(const std::string &mac) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-01-16 12:23:07 +01:00
|
|
|
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name AccessPoint operations */
|
|
|
|
//@{
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Returns the number of access points
|
2011-06-16 14:10:43 +02:00
|
|
|
static unsigned int nb_aps(void) ;
|
2011-06-29 16:13:44 +02:00
|
|
|
/// Verify the existence of an AP
|
|
|
|
static bool ap_exists(const std::string &mac) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Reads the AccessPoint corresponding to a given MAC address
|
2010-01-12 00:31:22 +01:00
|
|
|
static const AccessPoint& get_ap(const std::string &mac) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Searches for an AccessPoint given its MAC address and
|
|
|
|
/// creates it if it does not exist
|
2010-04-01 11:03:24 +02:00
|
|
|
static const AccessPoint& find_create_ap(const std::string &mac) ;
|
2011-06-29 11:05:58 +02:00
|
|
|
/// Searches for an AccessPoint and create it if it does not exist
|
|
|
|
static const AccessPoint& find_create_ap(const AccessPoint &source) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Returns a reference to the AccessPoint corresponding to a
|
|
|
|
/// given MAC address
|
2010-01-12 00:31:22 +01:00
|
|
|
static AccessPoint& getw_ap(const std::string &mac) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Updates the friis indexes of all the APs
|
2010-06-10 15:57:03 +02:00
|
|
|
static void update_all_friis_indexes(void) ;
|
2011-06-15 15:30:49 +02:00
|
|
|
static double ap_matrix_get_ss(const std::string &mac_transmitter,
|
|
|
|
const std::string &mac_receiver) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-02-02 17:34:58 +01:00
|
|
|
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name ReferencePoint operations */
|
|
|
|
//@{
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Returns the number of reference points
|
2011-06-16 14:10:43 +02:00
|
|
|
static unsigned int nb_reference_points(void) ;
|
2011-06-15 15:13:18 +02:00
|
|
|
/// Reads the ReferencePoint at the given coordinates
|
|
|
|
static const ReferencePoint&
|
|
|
|
get_reference_point(const ReferencePoint &point) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Searches for a ReferencePoint and adds it if it does not exist
|
2010-02-19 11:42:04 +01:00
|
|
|
static const ReferencePoint&
|
|
|
|
find_create_reference_point(const ReferencePoint &point) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Searches for the closest ReferencePoint (in the signal
|
2011-05-09 16:39:55 +02:00
|
|
|
/// strength space) to a given Request
|
2010-06-02 12:37:43 +02:00
|
|
|
static const ReferencePoint&
|
|
|
|
closest_reference_point(const Request &request) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-02-19 11:42:04 +01:00
|
|
|
|
2010-06-23 17:45:59 +02:00
|
|
|
/** @name CalibrationRequest operations */
|
|
|
|
//@{
|
2011-06-27 10:24:59 +02:00
|
|
|
/// Returns the number of calibration requests
|
|
|
|
static unsigned int nb_calibration_requests(void) ;
|
2011-06-17 12:35:14 +02:00
|
|
|
/// \brief Searches for a CalibrationRequest, adds it if it does
|
|
|
|
/// not exist, and links it to its reference point
|
|
|
|
static void store_calibration_request(
|
|
|
|
const CalibrationRequest &request) ;
|
2011-06-20 11:43:17 +02:00
|
|
|
/// Deletes a CalibrationRequest
|
|
|
|
static void delete_calibration_request(
|
|
|
|
const CalibrationRequest &request) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Searches for a CalibrationRequest and adds it if it does not exist
|
2010-02-19 11:42:04 +01:00
|
|
|
static const CalibrationRequest&
|
|
|
|
find_create_calibration_request(const CalibrationRequest &request) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// \brief Searches for the closest CalibrationRequest (in the signal
|
2011-05-09 16:42:30 +02:00
|
|
|
/// strength space) to a given Request
|
|
|
|
static const CalibrationRequest&
|
|
|
|
closest_calibration_request(const Request &request) ;
|
2010-06-23 17:45:59 +02:00
|
|
|
//@}
|
2010-02-19 11:42:04 +01:00
|
|
|
|
2010-02-02 17:34:58 +01:00
|
|
|
/// Deletes all elements in all attributes
|
|
|
|
static void clear(void) ;
|
2010-01-12 00:31:22 +01:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-16 14:10:43 +02:00
|
|
|
/* *** Building operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int Stock::nb_buildings()
|
|
|
|
{
|
|
|
|
return buildings.size() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Waypoint operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int Stock::nb_waypoints()
|
|
|
|
{
|
|
|
|
return waypoints.size() ;
|
|
|
|
}
|
2010-01-12 00:31:22 +01:00
|
|
|
|
|
|
|
|
2010-04-13 10:47:10 +02:00
|
|
|
inline const Waypoint& Stock::
|
|
|
|
find_create_waypoint(const Waypoint &point)
|
|
|
|
{
|
|
|
|
Waypoint& found =
|
|
|
|
const_cast<Waypoint&>(
|
|
|
|
find_create_waypoint(static_cast<Point3D>(point))) ;
|
|
|
|
found.add_buildings(point) ;
|
|
|
|
return found ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-16 14:10:43 +02:00
|
|
|
|
|
|
|
/* *** Mobile operations *** */
|
|
|
|
|
|
|
|
|
2011-07-19 18:43:54 +02:00
|
|
|
inline unsigned int Stock::nb_mobiles()
|
|
|
|
{
|
|
|
|
return mobiles.size() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* If the Mobile corresponding to \em mac does not exist, it is created.
|
|
|
|
* @param mac The MAC address of the Mobile to search for. It must be a
|
|
|
|
* valid MAC address, as no check is performed.
|
|
|
|
* @return A modifiable reference to the Mobile.
|
|
|
|
*/
|
2010-01-12 00:31:22 +01:00
|
|
|
inline Mobile& Stock::getw_mobile(const std::string &mac)
|
|
|
|
{
|
|
|
|
return mobiles[mac] ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-16 14:10:43 +02:00
|
|
|
|
|
|
|
/* *** AccessPoint operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int Stock::nb_aps()
|
|
|
|
{
|
|
|
|
return aps.size() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* If the AccessPoint corresponding to \em mac does not exist, it is
|
|
|
|
* created.
|
|
|
|
* @param mac The MAC address of the AccessPoint to search for.
|
|
|
|
* It must be a valid MAC address, as no check is performed.
|
|
|
|
* @return A modifiable reference to the AccessPoint.
|
|
|
|
*/
|
2010-01-12 00:31:22 +01:00
|
|
|
inline AccessPoint& Stock::getw_ap(const std::string &mac)
|
|
|
|
{
|
|
|
|
return aps[mac] ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-16 14:10:43 +02:00
|
|
|
/* *** ReferencePoint operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int Stock::nb_reference_points()
|
|
|
|
{
|
|
|
|
return reference_points.size() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-27 10:24:59 +02:00
|
|
|
/* *** CalibrationRequest operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int Stock::nb_calibration_requests()
|
|
|
|
{
|
|
|
|
return calibration_requests.size() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-12 00:31:22 +01:00
|
|
|
#endif // _OWLPS_POSITIONING_STOCK_HH_
|