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
|
|
|
|
static std::tr1::unordered_set<ReferencePoint> reference_points ;
|
|
|
|
|
|
|
|
/// List of known CalibrationRequest
|
|
|
|
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
|
|
|
|
|
2010-01-12 00:31:22 +01:00
|
|
|
public:
|
2010-04-02 14:03:55 +02:00
|
|
|
/// Read the Building corresponding to a given name
|
|
|
|
static const Building& get_building(const std::string &name) ;
|
|
|
|
/// Look for a Building and create it if it does not exist
|
|
|
|
static const Building& find_create_building(const std::string &name) ;
|
|
|
|
|
2010-04-13 10:47:10 +02:00
|
|
|
/// Look for a Waypoint and add it if it does not exist
|
|
|
|
static const Waypoint&
|
|
|
|
find_create_waypoint(const Waypoint &point) ;
|
|
|
|
/// \brief Look for a Waypoint from its coordinates and add it if it
|
|
|
|
/// does not exist
|
|
|
|
static const Waypoint&
|
|
|
|
find_create_waypoint(const Point3D &point) ;
|
|
|
|
/// \brief Delete a Building from the building list of a Waypoint;
|
|
|
|
/// delete the Waypoint if it is not linked to any Building any more
|
|
|
|
static void waypoint_remove_building(const Waypoint &point,
|
|
|
|
const Building *building) ;
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Read 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) ;
|
2010-04-01 11:03:24 +02:00
|
|
|
/// Look for a Mobile and create it if it does not exist
|
|
|
|
static const Mobile& find_create_mobile(const std::string &mac) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Get 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-01-16 12:23:07 +01:00
|
|
|
|
|
|
|
/// Read 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) ;
|
2010-04-01 11:03:24 +02:00
|
|
|
/// Look for an AccessPoint and create it if it does not exist
|
|
|
|
static const AccessPoint& find_create_ap(const std::string &mac) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Get 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) ;
|
2010-06-10 15:57:03 +02:00
|
|
|
/// Update the friis indexes of all the APs
|
|
|
|
static void update_all_friis_indexes(void) ;
|
2010-02-02 17:34:58 +01:00
|
|
|
|
2010-04-02 14:03:55 +02:00
|
|
|
/// Look for a ReferencePoint and add it if it does not exist
|
2010-02-19 11:42:04 +01:00
|
|
|
static const ReferencePoint&
|
|
|
|
find_create_reference_point(const ReferencePoint &point) ;
|
2010-06-02 12:37:43 +02:00
|
|
|
/// \brief Look for the closest ReferencePoint (in the signal strength
|
|
|
|
/// space) to a given Request
|
|
|
|
static const ReferencePoint&
|
|
|
|
closest_reference_point(const Request &request) ;
|
2010-02-19 11:42:04 +01:00
|
|
|
|
2010-04-02 14:03:55 +02:00
|
|
|
/// Look for a CalibrationRequest and add it if it does not exist
|
2010-02-19 11:42:04 +01:00
|
|
|
static const CalibrationRequest&
|
|
|
|
find_create_calibration_request(const CalibrationRequest &request) ;
|
|
|
|
|
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
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-19 11:42:04 +01:00
|
|
|
/* *** Accessors *** */
|
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 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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] ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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] ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_STOCK_HH_
|