284 lines
8.5 KiB
C++
284 lines
8.5 KiB
C++
#ifndef _OWLPS_POSITIONING_STOCK_HH_
|
|
#define _OWLPS_POSITIONING_STOCK_HH_
|
|
|
|
#include "building.hh"
|
|
#include "waypoint.hh"
|
|
#include "mobile.hh"
|
|
#include "accesspoint.hh"
|
|
#include "referencepoint.hh"
|
|
#include "calibrationrequest.hh"
|
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
|
#include <boost/tr1/unordered_set.hpp>
|
|
|
|
/// Storage class
|
|
class Stock
|
|
{
|
|
private:
|
|
/// List of known Building
|
|
/** The string key of the map is the Building name. */
|
|
static std::tr1::unordered_map<std::string, Building> buildings ;
|
|
|
|
/// List of known Waypoint
|
|
static std::tr1::unordered_map<Point3D, Waypoint> waypoints ;
|
|
|
|
/// List of known Mobile
|
|
/** The string key of the map is the Mobile MAC address. */
|
|
static std::tr1::unordered_map<std::string, Mobile> mobiles ;
|
|
|
|
/// Number of generated "virtual" mobiles
|
|
static uint32_t nb_virtual_mobiles ;
|
|
|
|
/// List of known AccessPoint
|
|
/** The string key of the map is the AccessPoint MAC address. */
|
|
static std::tr1::unordered_map<std::string, AccessPoint> aps ;
|
|
|
|
/// List of known ReferencePoint
|
|
static std::tr1::unordered_set
|
|
<ReferencePoint, boost::hash<ReferencePoint>, reference_point_equal_to>
|
|
reference_points ;
|
|
|
|
/// List of known CalibrationRequest
|
|
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
|
|
|
|
/** @name ReferencePoint operations */
|
|
//@{
|
|
/// Generates a single reference point
|
|
static void generate_reference_point(const Point3D &point) ;
|
|
//@}
|
|
|
|
/** @name CalibrationRequest operations */
|
|
//@{
|
|
/// Delete calibration requests that do not come from the APs
|
|
static void delete_non_ap_calibration_requests(void) ;
|
|
//@}
|
|
|
|
public:
|
|
/** @name Building operations */
|
|
//@{
|
|
/// Returns the number of buildings
|
|
static unsigned int nb_buildings(void) ;
|
|
/// Reads the Building corresponding to a given name
|
|
static const Building& get_building(const std::string &name) ;
|
|
/// Searches for a Building and creates it if it does not exist
|
|
static const Building& find_create_building(const std::string &name) ;
|
|
/// Searches the Area in which \em point is
|
|
static const Area* in_which_area_is(const Point3D point) ;
|
|
//@}
|
|
|
|
/** @name Waypoint operations */
|
|
//@{
|
|
/// Returns the number of waypoints
|
|
static unsigned int nb_waypoints(void) ;
|
|
/// Searches for a Waypoint and adds it if it does not exist
|
|
static const Waypoint&
|
|
find_create_waypoint(const Waypoint &point) ;
|
|
/// \brief Searches for a Waypoint from its coordinates and adds it
|
|
/// if it does not exist
|
|
static const Waypoint&
|
|
find_create_waypoint(const Point3D &point) ;
|
|
/// \brief 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) ;
|
|
//@}
|
|
|
|
/** @name Mobile operations */
|
|
//@{
|
|
/// Returns the number of mobiles
|
|
static unsigned int nb_mobiles(void) ;
|
|
/// Verify the existence of a mobile
|
|
static bool mobile_exists(const std::string &mac) ;
|
|
/// Reads the Mobile corresponding to a given MAC address
|
|
static const Mobile& get_mobile(const std::string &mac) ;
|
|
/// \brief Searches for a Mobile given its MAC address and creates
|
|
/// it if it does not exist
|
|
static const Mobile& find_create_mobile(const std::string &mac) ;
|
|
/// Searches for a Mobile and create it if it does not exist
|
|
static const Mobile& find_create_mobile(const Mobile &source) ;
|
|
/// \brief Returns a reference to the Mobile corresponding to a
|
|
/// given MAC address
|
|
static Mobile& getw_mobile(const std::string &mac) ;
|
|
//@}
|
|
|
|
/** @name AccessPoint operations */
|
|
//@{
|
|
/// Returns the number of access points
|
|
static unsigned int nb_aps(void) ;
|
|
/// Returns a reference to the AP list
|
|
static
|
|
std::tr1::unordered_map<std::string, AccessPoint>& get_aps(void) ;
|
|
/// Verify the existence of an AP
|
|
static bool ap_exists(const std::string &mac) ;
|
|
/// Reads the AccessPoint corresponding to a given MAC address
|
|
static const AccessPoint& get_ap(const std::string &mac) ;
|
|
/// \brief Searches for an AccessPoint given its MAC address and
|
|
/// creates it if it does not exist
|
|
static const AccessPoint& find_create_ap(const std::string &mac) ;
|
|
/// Searches for an AccessPoint and create it if it does not exist
|
|
static const AccessPoint& find_create_ap(const AccessPoint &source) ;
|
|
/// \brief Returns a reference to the AccessPoint corresponding to a
|
|
/// given MAC address
|
|
static AccessPoint& getw_ap(const std::string &mac) ;
|
|
/// Updates the friis indexes of all the APs
|
|
static void update_all_friis_indexes(void) ;
|
|
/// \brief Returns the signal strenth received by an AP mac_receiver
|
|
/// from an AP mac_transmitter
|
|
static double ap_matrix_get_ss(const std::string &mac_transmitter,
|
|
const std::string &mac_receiver) ;
|
|
/// Checks if a Point3D is the coordinate of an existing AP
|
|
static bool is_ap_coordinate(const Point3D &coord) ;
|
|
//@}
|
|
|
|
/** @name ReferencePoint operations */
|
|
//@{
|
|
/// Returns the number of reference points
|
|
static unsigned int nb_reference_points(void) ;
|
|
/// Verify the existence of a reference point at the given coordinates
|
|
static bool reference_point_exists(const ReferencePoint &point) ;
|
|
/// Reads the ReferencePoint at the given coordinates
|
|
static const ReferencePoint&
|
|
get_reference_point(const ReferencePoint &point) ;
|
|
/// Searches for a ReferencePoint and adds it if it does not exist
|
|
static const ReferencePoint&
|
|
find_create_reference_point(const ReferencePoint &point) ;
|
|
/// \brief Searches for the closest ReferencePoint (in the signal
|
|
/// strength space) to a given Request
|
|
static const ReferencePoint&
|
|
closest_reference_point(const Request &request) ;
|
|
/// \brief Generates reference points from the reference points
|
|
/// corresponding to APs
|
|
static void regenerate_reference_points(void) ;
|
|
//@}
|
|
|
|
/** @name CalibrationRequest operations */
|
|
//@{
|
|
/// Returns the number of calibration requests
|
|
static unsigned int nb_calibration_requests(void) ;
|
|
/// \brief Searches for a CalibrationRequest, adds it if it does
|
|
/// not exist, and links it to its reference point
|
|
static const CalibrationRequest& store_calibration_request(
|
|
const CalibrationRequest &request) ;
|
|
/// Deletes a CalibrationRequest
|
|
static void delete_calibration_request(
|
|
const CalibrationRequest &request) ;
|
|
/// Searches for a CalibrationRequest and adds it if it does not exist
|
|
static const CalibrationRequest&
|
|
find_create_calibration_request(const CalibrationRequest &request) ;
|
|
/// \brief Searches for the closest CalibrationRequest (in the signal
|
|
/// strength space) to a given Request
|
|
static const CalibrationRequest&
|
|
closest_calibration_request(const Request &request) ;
|
|
//@}
|
|
|
|
/// Deletes all elements in all attributes
|
|
static void clear(void) ;
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Building operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_buildings()
|
|
{
|
|
return buildings.size() ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Waypoint operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_waypoints()
|
|
{
|
|
return waypoints.size() ;
|
|
}
|
|
|
|
|
|
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 ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Mobile operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_mobiles()
|
|
{
|
|
return mobiles.size() ;
|
|
}
|
|
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
inline Mobile& Stock::getw_mobile(const std::string &mac)
|
|
{
|
|
return mobiles[mac] ;
|
|
}
|
|
|
|
|
|
|
|
/* *** AccessPoint operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_aps()
|
|
{
|
|
return aps.size() ;
|
|
}
|
|
|
|
|
|
inline
|
|
std::tr1::unordered_map<std::string, AccessPoint>& Stock::get_aps()
|
|
{
|
|
return aps ;
|
|
}
|
|
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
inline AccessPoint& Stock::getw_ap(const std::string &mac)
|
|
{
|
|
return aps[mac] ;
|
|
}
|
|
|
|
|
|
|
|
/* *** ReferencePoint operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_reference_points()
|
|
{
|
|
return reference_points.size() ;
|
|
}
|
|
|
|
|
|
|
|
/* *** CalibrationRequest operations *** */
|
|
|
|
|
|
inline unsigned int Stock::nb_calibration_requests()
|
|
{
|
|
return calibration_requests.size() ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_STOCK_HH_
|