[Positioner] Get rid of Boost's unordered_*

Stop using Boost for unordered_set, unordered_map and hashes.
This commit is contained in:
Matteo Cypriani 2013-05-30 14:13:44 -04:00
parent 081c559fc5
commit f352295e9d
40 changed files with 248 additions and 199 deletions

View File

@ -17,7 +17,6 @@
#include "posexcept.hh"
using namespace std ;
using std::tr1::unordered_map ;

View File

@ -25,7 +25,7 @@
#include <sstream>
using namespace std ;
using std::tr1::unordered_map ;
/* *** Static attribute definitions *** */

View File

@ -21,7 +21,7 @@ class Point3D ;
#include "measurement.hh"
#include <vector>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
/**
* The class Autocalibration contains the code used to generate single
@ -38,7 +38,7 @@ private:
} ;
/// Current AP to generate a SS for
std::tr1::unordered_map<std::string, AccessPoint>::const_iterator rx ;
std::unordered_map<std::string, AccessPoint>::const_iterator rx ;
/// Angle P-RX-O, O being the origin of the trigonometric circle
float origin_angle ;
/// Selected transmitter APs
@ -50,19 +50,19 @@ private:
*/
std::multimap<double,
std::pair<double,
std::tr1::unordered_map<
std::unordered_map<
std::string, AccessPoint>::const_iterator> >
sorted_negative_angles ;
/// Angles of the transmitter APs (after M on the trigonometric circle)
std::multimap<double,
std::pair<double,
std::tr1::unordered_map<
std::unordered_map<
std::string, AccessPoint>::const_iterator> >
sorted_positive_angles ;
/// Characteristics of the virtual mobile
double vmob_gain, vmob_pow ;
/// Generated measurements' list
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
protected:
/// Number of generated "virtual" mobiles
@ -78,7 +78,7 @@ protected:
/// Computes the weight of the selected AP(s)
void weight_aps(void) ;
void init_ap(
std::map<double, std::pair<double, std::tr1::unordered_map<
std::map<double, std::pair<double, std::unordered_map<
std::string, AccessPoint>::const_iterator> >::const_iterator s) ;
/// Weights two APs according to their angles
void weight_2_aps(void) ;

View File

@ -19,8 +19,6 @@
using namespace std ;
using std::tr1::unordered_set ;
using std::tr1::unordered_map ;

View File

@ -20,8 +20,8 @@ class Waypoint ;
#include <string>
#include <ostream>
#include <boost/tr1/unordered_set.hpp>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_set>
#include <unordered_map>
/// Represents a building, containing one or more Area
class Building
@ -29,9 +29,9 @@ class Building
protected:
std::string name ;
/// List of Area contained in the Building
std::tr1::unordered_map<std::string, Area*> areas ;
std::unordered_map<std::string, Area*> areas ;
/// List of Waypoint in the Building
std::tr1::unordered_set<Waypoint*> waypoints ;
std::unordered_set<Waypoint*> waypoints ;
public :
Building(const std::string &_name = "Unnamed building"):
@ -46,9 +46,9 @@ public :
/** @name Read accessors */
//@{
const std::string& get_name(void) const ;
const std::tr1::unordered_map<std::string, Area*>&
const std::unordered_map<std::string, Area*>&
get_areas(void) const ;
const std::tr1::unordered_set<Waypoint*>& get_waypoints(void) const ;
const std::unordered_set<Waypoint*>& get_waypoints(void) const ;
//@}
/** @name Write accessors */
@ -82,14 +82,14 @@ inline const std::string& Building::get_name() const
}
inline const std::tr1::unordered_map<std::string, Area*>&
inline const std::unordered_map<std::string, Area*>&
Building::get_areas() const
{
return areas ;
}
inline const std::tr1::unordered_set<Waypoint*>&
inline const std::unordered_set<Waypoint*>&
Building::get_waypoints() const
{
return waypoints ;

View File

@ -13,7 +13,6 @@
#include "calibrationrequest.hh"
#include "referencepoint.hh"
@ -93,17 +92,3 @@ operator==(const CalibrationRequest &source) const
direction == source.direction &&
reference_point == source.reference_point ;
}
size_t hash_value(const CalibrationRequest &source)
{
size_t seed = 0 ;
boost::hash_combine(seed, static_cast<Request>(source)) ;
boost::hash_combine(seed, source.direction) ;
if (source.reference_point != NULL)
boost::hash_combine(seed, *source.reference_point) ;
return seed ;
}

View File

@ -15,10 +15,10 @@
#ifndef _OWLPS_POSITIONING_CALIBRATIONREQUEST_HH_
#define _OWLPS_POSITIONING_CALIBRATIONREQUEST_HH_
class ReferencePoint ;
#include "request.hh"
#include "direction.hh"
#include "referencepoint.hh"
#include "posutil.hh"
/// Represents a calibration Request sent by a mobile
class CalibrationRequest: public Request
@ -66,9 +66,6 @@ public:
bool operator==(const CalibrationRequest &source) const ;
bool operator!=(const CalibrationRequest &source) const ;
//@}
/// Hashes a CalibrationRequest
friend std::size_t hash_value(const CalibrationRequest &source) ;
} ;
@ -118,4 +115,25 @@ operator!=(const CalibrationRequest &source) const
namespace std
{
template<> struct hash<CalibrationRequest>
{
public:
size_t operator()(const CalibrationRequest &source) const
{
size_t seed = 0 ;
PosUtil::hash_combine(seed, static_cast<Request>(source)) ;
PosUtil::hash_combine(seed, source.get_direction()) ;
if (source.get_reference_point() != NULL)
PosUtil::hash_combine(seed, *source.get_reference_point()) ;
return seed ;
}
} ;
}
#endif // _OWLPS_POSITIONING_CALIBRATIONREQUEST_HH_

View File

@ -15,8 +15,6 @@
#include "direction.hh"
#include "posexcept.hh"
#include <boost/functional/hash.hpp>
/* *** Constructors *** */
@ -80,10 +78,3 @@ Direction::operator std::string() const
}
return "Bad direction!" ;
}
size_t hash_value(const Direction &source)
{
return boost::hash_value(source.direction) ;
}

View File

@ -49,9 +49,6 @@ public:
operator int(void) const ;
operator std::string(void) const ;
//@}
// Hashes a Direction
friend size_t hash_value(const Direction &source) ;
} ;
@ -94,4 +91,19 @@ inline Direction::operator int() const
namespace std
{
template<> struct hash<Direction>
{
public:
size_t operator()(const Direction &source) const
{
hash<int> h ;
return h(source) ;
}
} ;
}
#endif // _OWLPS_POSITIONING_DIRECTION_HH_

View File

@ -20,10 +20,9 @@
#include "configuration.hh"
#include <iostream>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
using namespace std ;
using std::tr1::unordered_map ;

View File

@ -23,10 +23,9 @@
#include <cstdio> // For perror()
#include <unistd.h> // For close()
#include <arpa/inet.h> // For inet_ntop()
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
using namespace std ;
using std::tr1::unordered_map ;

View File

@ -15,7 +15,7 @@
#include "minmax.hh"
#include "accesspoint.hh"
using std::tr1::unordered_map ;
using namespace std ;

View File

@ -23,7 +23,7 @@ class MinMax: public TrilaterationMethod
private:
float min ;
Point3D centre ;
std::tr1::unordered_map<AccessPoint*, float> const *ap_distances ;
std::unordered_map<AccessPoint*, float> const *ap_distances ;
void iterate(float x, float y, float z) ;
@ -45,9 +45,9 @@ public:
~MinMax(void) {}
Point3D trilaterate(
const std::tr1::unordered_map<AccessPoint*, float> &_ap_distances) ;
const std::unordered_map<AccessPoint*, float> &_ap_distances) ;
Point3D trilaterate_2d(
const std::tr1::unordered_map<AccessPoint*, float> &_ap_distances,
const std::unordered_map<AccessPoint*, float> &_ap_distances,
float z) ;
} ;

View File

@ -17,7 +17,6 @@
#include "posexcept.hh"
#include <sstream>
#include <boost/functional/hash.hpp>
using namespace std ;
@ -197,16 +196,3 @@ ostream& operator<<(ostream &os, const Point3D &p)
os << "(" << p.x << ";" << p.y << ";" << p.z << ")" ;
return os ;
}
size_t hash_value(const Point3D &source)
{
size_t seed = 0 ;
boost::hash_combine(seed, source.x) ;
boost::hash_combine(seed, source.y) ;
boost::hash_combine(seed, source.z) ;
return seed ;
}

View File

@ -15,6 +15,8 @@
#ifndef _OWLPS_POSITIONING_POINT3D_HH_
#define _OWLPS_POSITIONING_POINT3D_HH_
#include "posutil.hh"
#include <string>
#include <ostream>
#include <cmath>
@ -92,9 +94,6 @@ public:
/// Displays a Point3D
friend std::ostream& operator<<(std::ostream &os, const Point3D &p) ;
/// Hashes a Point3D
friend std::size_t hash_value(const Point3D &source) ;
} ;
@ -235,4 +234,24 @@ inline bool Point3D::operator>=(const Point3D &source) const
namespace std
{
template<> struct hash<Point3D>
{
public:
size_t operator()(const Point3D &source) const
{
size_t seed = 0 ;
PosUtil::hash_combine(seed, source.get_x()) ;
PosUtil::hash_combine(seed, source.get_y()) ;
PosUtil::hash_combine(seed, source.get_z()) ;
return seed ;
}
} ;
}
#endif // _OWLPS_POSITIONING_POINT3D_HH_

View File

@ -26,10 +26,9 @@
#include <owlps.h>
#include <iostream>
#include <boost/tr1/unordered_set.hpp>
#include <unordered_set>
using namespace std ;
using std::tr1::unordered_set ;

View File

@ -23,7 +23,6 @@
#include <cmath>
using namespace std ;
using std::tr1::unordered_map ;

View File

@ -17,7 +17,7 @@
class Measurement ;
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
#include <boost/algorithm/string/case_conv.hpp>
#include <stdint.h> // <cstdint> is not C++ 98 compliant
@ -28,6 +28,12 @@ public:
/// The speed of light, in m/s
static const unsigned long LIGHT_SPEED = 299792458 ;
/** @name Hashes */
//@{
template <class T> static void hash_combine(
std::size_t &seed, const T &v) ;
//@}
/** @name Maths */
//@{
/// Returns the radian value of \em degrees
@ -42,12 +48,12 @@ public:
//@{
/// Mutually completes two Measurement lists with missing APs
static void complete_with_dummy_measurements(
std::tr1::unordered_map<std::string, Measurement> &measurements1,
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
std::unordered_map<std::string, Measurement> &measurements1,
std::unordered_map<std::string, Measurement> &measurements2) ;
/// Computes the similarity of two Measurement lists
static float similarity(
std::tr1::unordered_map<std::string, Measurement> &measurements1,
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
std::unordered_map<std::string, Measurement> &measurements1,
std::unordered_map<std::string, Measurement> &measurements2) ;
//@}
/** @name Wi-Fi */
@ -65,6 +71,18 @@ public:
/* *** Hashes *** */
template <class T> inline void PosUtil::
hash_combine(std::size_t &seed, const T &v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2) ;
}
/* *** Maths *** */

View File

@ -17,7 +17,6 @@
#include "stock.hh"
using namespace std ;
using std::tr1::unordered_map ;
@ -397,15 +396,3 @@ ostream &operator<<(ostream &os, const ReferencePoint &rp)
return os ;
}
/**
* This is a simple call to hash_value(Point3D), because we do not want
* to take care of the CalibrationRequest list to hash the
* ReferencePoint.
*/
size_t hash_value(const ReferencePoint &source)
{
return hash_value(static_cast<Point3D>(source)) ;
}

View File

@ -24,7 +24,7 @@ class Request ;
#include <vector>
#include <ostream>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
/// Represents a reference point in 3-D space
class ReferencePoint: public Point3D
@ -37,10 +37,10 @@ protected:
/** @name Read accessors */
//@{
std::tr1::unordered_map<std::string, Measurement>
std::unordered_map<std::string, Measurement>
get_all_measurements(void) const ;
/// Returns all the measurements sent by the given mobile
std::tr1::unordered_map<std::string, Measurement>
std::unordered_map<std::string, Measurement>
get_all_measurements(const std::string &mac_transmitter) const ;
//@}
@ -105,9 +105,6 @@ public:
/// Displays a ReferencePoint
friend std::ostream &operator<<(
std::ostream &os, const ReferencePoint &rp) ;
/// Hashes a ReferencePoint
friend std::size_t hash_value(const ReferencePoint &source) ;
} ;
@ -151,9 +148,30 @@ inline bool ReferencePoint::operator!=(const ReferencePoint &source) const
struct reference_point_equal_to:
public std::binary_function<ReferencePoint, ReferencePoint, bool>
namespace std
{
template<> struct hash<ReferencePoint>
{
public:
/**
* This is a simple call to the hash function for Point3D, because we
* do not want to take care of the CalibrationRequest list to hash the
* ReferencePoint.
*/
size_t operator()(const ReferencePoint &source) const
{
hash<Point3D> h ;
return h(source) ;
}
} ;
template<> struct equal_to<ReferencePoint>
{
public:
/**
* We want to take into account only the coordinates when comparing
* two ReferencePoint in a container.
*/
bool operator()(const ReferencePoint &source1,
const ReferencePoint &source2) const
{
@ -161,6 +179,7 @@ struct reference_point_equal_to:
static_cast<Point3D>(source1) == static_cast<Point3D>(source2) ;
}
} ;
}

View File

@ -15,12 +15,10 @@
#include "request.hh"
#include "calibrationrequest.hh"
#include "referencepoint.hh"
#include "mobile.hh"
#include <sstream>
using namespace std ;
using std::tr1::unordered_map ;
@ -30,7 +28,7 @@ using std::tr1::unordered_map ;
Request::Request(
const Mobile *_mobile,
const Timestamp &_time_sent,
const std::tr1::unordered_map<string, Measurement> &_measurements
const unordered_map<string, Measurement> &_measurements
):
type(OWL_REQUEST_UNDEFINED), nb_packets(1),
mobile(const_cast<Mobile*>(_mobile)), time_sent(_time_sent),
@ -40,7 +38,7 @@ Request::Request(
}
Request::Request(const std::tr1::unordered_map<string, Measurement>
Request::Request(const unordered_map<string, Measurement>
&_measurements):
type(OWL_REQUEST_UNDEFINED), nb_packets(1),
mobile(NULL), measurements(_measurements), real_position(NULL)
@ -51,7 +49,7 @@ Request::Request(const std::tr1::unordered_map<string, Measurement>
Request::Request(
const Timestamp &_time_sent,
const std::tr1::unordered_map<string, Measurement> &_measurements
const unordered_map<string, Measurement> &_measurements
):
type(OWL_REQUEST_UNDEFINED), nb_packets(1),
mobile(NULL), time_sent(_time_sent),
@ -269,25 +267,3 @@ ostream& operator<<(ostream &os, const Request &r)
return os ;
}
/**
* The Mobile MAC address and the Timestamp are sufficient to identify
* uniquely a Request.
*/
size_t hash_value(const Request &source)
{
size_t seed = 0 ;
boost::hash_combine(seed, source.type) ;
boost::hash_combine(seed, source.nb_packets) ;
boost::hash_combine(seed, source.time_sent) ;
boost::hash_combine(seed, source.time_received) ;
if (source.mobile)
boost::hash_combine(seed, source.mobile->get_mac_addr()) ;
if (source.real_position)
boost::hash_combine(seed, source.real_position) ;
return seed ;
}

View File

@ -15,16 +15,16 @@
#ifndef _OWLPS_POSITIONING_REQUEST_HH_
#define _OWLPS_POSITIONING_REQUEST_HH_
class Mobile ;
#include "mobile.hh"
#include "measurement.hh"
#include "timestamp.hh"
#include "posutil.hh"
#include <owlps.h>
#include <ctime>
#include <vector>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
#include <ostream>
/// Represents a request sent by a Mobile
@ -44,7 +44,7 @@ protected:
/// List of Measurement of the request
/** Note that this is not a pointer list, values are actually stored.
The \em string parameter is the MAC address of the receiver AP. */
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
/// \brief Real coordinates of the request (normally unavailable for a
/// standard positioning request)
Point3D *real_position ;
@ -57,17 +57,17 @@ protected:
public:
Request(const Mobile *_mobile = NULL,
const Timestamp &_time_sent = Timestamp(),
const std::tr1::unordered_map<std::string, Measurement>
const std::unordered_map<std::string, Measurement>
&_measurements =
std::tr1::unordered_map<std::string, Measurement>()) ;
std::unordered_map<std::string, Measurement>()) ;
Request(const std::tr1::unordered_map<std::string, Measurement>
Request(const std::unordered_map<std::string, Measurement>
&_measurements) ;
Request(const Timestamp &_time_sent,
const std::tr1::unordered_map<std::string, Measurement>
const std::unordered_map<std::string, Measurement>
&_measurements =
std::tr1::unordered_map<std::string, Measurement>()) ;
std::unordered_map<std::string, Measurement>()) ;
Request(const Request &source) ;
@ -81,7 +81,7 @@ public:
const Timestamp& get_time_sent(void) const ;
const Timestamp& get_time_received(void) const ;
/// Returns all the measurements
const std::tr1::unordered_map<std::string, Measurement>&
const std::unordered_map<std::string, Measurement>&
get_measurements(void) const ;
/// Returns the measurement made by the AP \em mac_receiver, if any
const Measurement*
@ -96,7 +96,7 @@ public:
void set_mobile(const Mobile *_mobile) ;
void set_time_sent(const Timestamp &_time_sent) ;
void received_now(void) ;
void set_measurements(const std::tr1::unordered_map
void set_measurements(const std::unordered_map
<std::string, Measurement> &_measurements) ;
void set_real_position(const Point3D &_real_position) ;
/// Reinitialises all attributes
@ -125,9 +125,6 @@ public:
/// Displays a Request
friend std::ostream& operator<<(std::ostream &os, const Request &r) ;
/// Hashes a Request
friend std::size_t hash_value(const Request &source) ;
} ;
@ -166,7 +163,7 @@ inline const Timestamp& Request::get_time_received() const
}
inline const std::tr1::unordered_map<std::string, Measurement>&
inline const std::unordered_map<std::string, Measurement>&
Request::get_measurements(void) const
{
return measurements ;
@ -214,7 +211,7 @@ inline void Request::received_now()
inline void Request::
set_measurements(const std::tr1::unordered_map<std::string, Measurement>
set_measurements(const std::unordered_map<std::string, Measurement>
&_measurements)
{
measurements = _measurements ;
@ -246,4 +243,33 @@ inline Request::operator bool() const
namespace std
{
template<> struct hash<Request>
{
public:
/**
* The Mobile MAC address and the Timestamp shourd be sufficient to
* identify uniquely a Request, but we test everything.
*/
size_t operator()(const Request &source) const
{
size_t seed = 0 ;
PosUtil::hash_combine(seed, source.get_type()) ;
PosUtil::hash_combine(seed, source.get_nb_packets()) ;
PosUtil::hash_combine(seed, source.get_time_sent()) ;
PosUtil::hash_combine(seed, source.get_time_received()) ;
if (source.get_mobile())
PosUtil::hash_combine(seed, source.get_mobile()->get_mac_addr()) ;
if (source.get_real_position())
PosUtil::hash_combine(seed, source.get_real_position()) ;
return seed ;
}
} ;
}
#endif // _OWLPS_POSITIONING_REQUEST_HH_

View File

@ -21,8 +21,6 @@
#include <iostream>
using namespace std ;
using std::tr1::unordered_map ;
using std::tr1::unordered_set ;
@ -36,9 +34,7 @@ unordered_map<string, Mobile> Stock::mobiles ;
unordered_map<string, AccessPoint> Stock::aps ;
unordered_set<ReferencePoint,
boost::hash<ReferencePoint>,
reference_point_equal_to> Stock::reference_points ;
unordered_set<ReferencePoint> Stock::reference_points ;
unordered_set<CalibrationRequest> Stock::calibration_requests ;
@ -379,7 +375,7 @@ const ReferencePoint& Stock::
find_create_reference_point(const ReferencePoint &point)
{
// unordered_set::insert() do all the job: see the documentation at
// http://boost.org/doc/libs/1_42_0/doc/html/boost/unordered_set.html
// http://en.cppreference.com/w/cpp/container/unordered_set/insert
pair<unordered_set<ReferencePoint>::iterator, bool> ret =
reference_points.insert(point) ;
return *ret.first ;

View File

@ -23,8 +23,8 @@
#include "referencepoint.hh"
#include "calibrationrequest.hh"
#include <boost/tr1/unordered_map.hpp>
#include <boost/tr1/unordered_set.hpp>
#include <unordered_map>
#include <unordered_set>
/// Storage class
class Stock
@ -34,26 +34,24 @@ 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 ;
static std::unordered_map<std::string, Building> buildings ;
/// List of known Waypoint
static std::tr1::unordered_map<Point3D, Waypoint> waypoints ;
static std::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 ;
static std::unordered_map<std::string, Mobile> 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 ;
static std::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 ;
static std::unordered_set<ReferencePoint> reference_points ;
/// List of known CalibrationRequest
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
static std::unordered_set<CalibrationRequest> calibration_requests ;
/** @name CalibrationRequest operations */
//@{
@ -126,7 +124,7 @@ public:
static unsigned int nb_aps(void) ;
/// Returns a reference to the AP list
static
std::tr1::unordered_map<std::string, AccessPoint>& get_aps(void) ;
std::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
@ -262,7 +260,7 @@ inline unsigned int Stock::nb_aps()
inline
std::tr1::unordered_map<std::string, AccessPoint>& Stock::get_aps()
std::unordered_map<std::string, AccessPoint>& Stock::get_aps()
{
return aps ;
}

View File

@ -15,7 +15,6 @@
#include "timestamp.hh"
#include "configuration.hh"
#include <boost/functional/hash.hpp>
#include <iostream>
using namespace std ;
@ -250,10 +249,3 @@ inline Timestamp::operator owl_timestamp(void) const
ret.tv_nsec = timestamp.tv_nsec ;
return ret ;
}
size_t hash_value(const Timestamp &source)
{
return boost::hash_value(static_cast<uint64_t>(source)) ;
}

View File

@ -276,4 +276,19 @@ inline Timestamp::operator uint64_t(void) const
namespace std
{
template<> struct hash<Timestamp>
{
public:
size_t operator()(const Timestamp &source) const
{
hash<uint64_t> h ;
return h(source) ;
}
} ;
}
#endif // _OWLPS_POSITIONING_TIMESTAMP_HH_

View File

@ -19,7 +19,6 @@
#include "posexcept.hh"
using namespace std ;
using std::tr1::unordered_map ;

View File

@ -24,7 +24,7 @@ class TrilaterationAlgorithm: public virtual PositioningAlgorithm
protected:
const Request *request ;
std::tr1::unordered_map<AccessPoint*, float> ap_distances ;
std::unordered_map<AccessPoint*, float> ap_distances ;
TrilaterationMethod *trilateration_method ;
/** @name Operations */

View File

@ -19,7 +19,7 @@ class AccessPoint ;
#include "point3d.hh"
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
/// Super-class of all trilateration methods
/**
@ -35,11 +35,11 @@ public:
/// Selects a point in 3D space
virtual Point3D trilaterate(
const std::tr1::unordered_map<AccessPoint*, float> &ap_distances) = 0 ;
const std::unordered_map<AccessPoint*, float> &ap_distances) = 0 ;
/// Selects a point in 2D space, given its vertical coordinate (z)
virtual Point3D trilaterate_2d(
const std::tr1::unordered_map<AccessPoint*, float> &ap_distances,
const std::unordered_map<AccessPoint*, float> &ap_distances,
float z) = 0 ;
} ;

View File

@ -18,7 +18,6 @@
#include <sstream>
using namespace std ;
using std::tr1::unordered_set ;

View File

@ -19,7 +19,7 @@ class Building ;
#include "point3d.hh"
#include <boost/tr1/unordered_set.hpp>
#include <unordered_set>
#include <ostream>
#include <stdexcept>
@ -34,7 +34,7 @@ class Waypoint: public Point3D
{
protected:
/// List of Building associated with the Waypoint
std::tr1::unordered_set<Building*> buildings ;
std::unordered_set<Building*> buildings ;
public:
Waypoint(const Building *_b = NULL, const float &_x = 0,
@ -52,7 +52,7 @@ public:
//@{
/// #buildings's first element read accessor
Building* get_1st_building(void) const ;
const std::tr1::unordered_set<Building*>& get_buildings(void) const ;
const std::unordered_set<Building*>& get_buildings(void) const ;
//@}
/** @name Write accessors */
@ -95,7 +95,7 @@ inline Building* Waypoint::get_1st_building() const
}
inline const std::tr1::unordered_set<Building*>&
inline const std::unordered_set<Building*>&
Waypoint::get_buildings() const
{
return buildings ;
@ -144,4 +144,25 @@ inline bool Waypoint::operator!=(const Waypoint &wp) const
namespace std
{
template<> struct hash<Waypoint>
{
public:
/**
* This is a simple call to the hash function for Point3D, because a
* waypoints should have unique coordinates independently from the
* building they belong to (the coordinate system is supposed to be
* common to all the buildings).
*/
size_t operator()(const Waypoint &source) const
{
hash<Point3D> h ;
return h(source) ;
}
} ;
}
#endif // _OWLPS_POSITIONING_WAYPOINT_HH_

View File

@ -27,9 +27,9 @@ public:
// Simple read accessors
Building b1 ;
TS_ASSERT_EQUALS(b1.get_name(), "Unnamed building") ;
std::tr1::unordered_map<std::string, Area*> areas1 ;
std::unordered_map<std::string, Area*> areas1 ;
TS_ASSERT_EQUALS(b1.get_areas(), areas1) ;
std::tr1::unordered_set<Waypoint*> waypoints1 ;
std::unordered_set<Waypoint*> waypoints1 ;
TS_ASSERT_EQUALS(b1.get_waypoints(), waypoints1) ;
// Write & read accessors

View File

@ -75,7 +75,7 @@ public:
for (std::vector<AccessPoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
{
std::tr1::unordered_map<std::string, Measurement>::const_iterator
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;
@ -100,7 +100,7 @@ public:
for (std::vector<AccessPoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
{
std::tr1::unordered_map<std::string, Measurement>::const_iterator
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;
@ -125,7 +125,7 @@ public:
for (std::vector<AccessPoint>::const_iterator i = TestUtil::aps.begin() ;
i != TestUtil::aps.end() ; ++i)
{
std::tr1::unordered_map<std::string, Measurement>::const_iterator
std::unordered_map<std::string, Measurement>::const_iterator
measurement_it1 =
request1.get_measurements().find(i->get_mac_addr()) ;
TS_ASSERT(request1.get_measurements().end() != measurement_it1) ;

View File

@ -17,7 +17,7 @@ public:
ap2(Point3D(10,0,0)),
ap3(Point3D(0,10,0)),
ap4(Point3D(5,5,4)) ;
std::tr1::unordered_map<AccessPoint*, float> ap_distances ;
std::unordered_map<AccessPoint*, float> ap_distances ;
ap_distances[&ap1] = 7.071 ;
ap_distances[&ap2] = 7.071 ;
ap_distances[&ap3] = 7.071 ;

View File

@ -64,7 +64,7 @@ public:
CalibrationRequest calibrationrequest1 ;
Measurement measurement1(&ap1) ;
measurement1.add_ss(-78) ;
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement1 ;
calibrationrequest1.set_measurements(measurements) ;
ReferencePoint referencepoint1 ;

View File

@ -11,7 +11,7 @@ public:
{
// Default constructor
Request r1 ;
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
Request r2(measurements) ;
TS_ASSERT_EQUALS(r1, r2) ;
@ -34,7 +34,7 @@ public:
current_time.now() ;
AccessPoint ap1(Point3D(1,2,3), "192.168.0.1", "aa:bb:cc:dd:ee:ff") ;
Measurement meas1(&ap1) ;
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = meas1 ;
Mobile mob1 ;
Request r1(&mob1, current_time, measurements) ;
@ -68,7 +68,7 @@ public:
{
// ==
struct timespec current_time ;
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
Measurement meas1 ;
measurements["aa:bb:cc:dd:ee:00"] = meas1 ;
clock_gettime(CLOCK_REALTIME, &current_time) ;

View File

@ -129,7 +129,7 @@ public:
CalibrationRequest calibrationrequest1 ;
Measurement measurement1(&ap1) ;
measurement1.add_ss(-23) ;
std::tr1::unordered_map<std::string, Measurement> measurements ;
std::unordered_map<std::string, Measurement> measurements ;
measurements["aa:bb:cc:dd:ee:ff"] = measurement1 ;
calibrationrequest1.set_measurements(measurements) ;
TS_ASSERT_THROWS(Stock::closest_reference_point(calibrationrequest1),

View File

@ -9,7 +9,6 @@
#include <sys/stat.h>
using namespace std ;
using std::tr1::unordered_map ;
vector<AccessPoint> TestUtil::aps ;
vector<Mobile> TestUtil::mobiles ;

View File

@ -10,7 +10,7 @@
#include <string>
#include <vector>
#include <boost/tr1/unordered_map.hpp>
#include <unordered_map>
class TestUtil
{
@ -40,8 +40,8 @@ public:
static bool request_equals(const Request &first,
const Request &second) ;
static bool measurements_unordered_map_equals(
std::tr1::unordered_map<std::string,Measurement> first,
std::tr1::unordered_map<std::string,Measurement> second) ;
std::unordered_map<std::string,Measurement> first,
std::unordered_map<std::string,Measurement> second) ;
static bool measurement_equals(const Measurement &first,
const Measurement &second) ;

View File

@ -47,7 +47,7 @@ public:
// Write & read accessors
Building b2("My Second Building") ;
wp1.add_building(&b2) ;
std::tr1::unordered_set<Building*> buildings ;
std::unordered_set<Building*> buildings ;
buildings.insert(&b1) ;
buildings.insert(&b2) ;
TS_ASSERT_EQUALS(wp1.get_buildings(), buildings) ;