#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 #include /// Storage class class Stock { private: /// List of known Building /** The string key of the map is the Building name. */ static std::tr1::unordered_map buildings ; /// List of known Waypoint static std::tr1::unordered_map waypoints ; /// List of known Mobile /** The string key of the map is the Mobile MAC address. */ static std::tr1::unordered_map mobiles ; /// List of known AccessPoint /** The string key of the map is the AccessPoint MAC address. */ static std::tr1::unordered_map aps ; /// List of known ReferencePoint static std::tr1::unordered_set reference_points ; /// List of known CalibrationRequest static std::tr1::unordered_set calibration_requests ; public: /** @name Building operations */ //@{ /// 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) ; //@} /** @name Waypoint operations */ //@{ /// 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) ; //@} /** @name Mobile operations */ //@{ /// Read the Mobile corresponding to a given MAC address static const Mobile& get_mobile(const std::string &mac) ; /// Look for a Mobile and create it if it does not exist static const Mobile& find_create_mobile(const std::string &mac) ; /// Get a reference to the Mobile corresponding to a given MAC address static Mobile& getw_mobile(const std::string &mac) ; //@} /** @name AccessPoint operations */ //@{ /// Read the AccessPoint corresponding to a given MAC address static const AccessPoint& get_ap(const std::string &mac) ; /// Look for an AccessPoint and create it if it does not exist static const AccessPoint& find_create_ap(const AccessPoint &source) ; /// \brief Look for an AccessPoint given its MAC address and create it /// if it does not exist static const AccessPoint& find_create_ap(const std::string &mac) ; /// Get a reference to the AccessPoint corresponding to a given MAC address static AccessPoint& getw_ap(const std::string &mac) ; /// Update the friis indexes of all the APs static void update_all_friis_indexes(void) ; //@} /** @name ReferencePoint operations */ //@{ /// Look for a ReferencePoint and add it if it does not exist static const ReferencePoint& find_create_reference_point(const ReferencePoint &point) ; /// \brief Look for the closest ReferencePoint (in the signal strength /// space) to a given Request static const ReferencePoint& closest_reference_point(const Request &request) ; //@} /** @name CalibrationRequest operations */ //@{ /// Look for a CalibrationRequest and add it if it does not exist static const CalibrationRequest& find_create_calibration_request(const CalibrationRequest &request) ; //@} /// Deletes all elements in all attributes static void clear(void) ; } ; /* *** Accessors *** */ inline const Waypoint& Stock:: find_create_waypoint(const Waypoint &point) { Waypoint& found = const_cast( find_create_waypoint(static_cast(point))) ; found.add_buildings(point) ; return found ; } /** * 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] ; } /** * 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] ; } #endif // _OWLPS_POSITIONING_STOCK_HH_