[Positioning] Inline short functions

Short functions (accessors and simple operators) are declared inline and
moved in header files, after the class definition.
This commit is contained in:
Matteo Cypriani 2010-01-05 11:50:24 +01:00
parent 96023d8285
commit d156e91379
21 changed files with 584 additions and 510 deletions

View File

@ -8,6 +8,5 @@
- C++ en action
Espaces de noms ? 109
Fonctions inline. 116
Réserver l'espace mémoire des vector avec reserve(). 217
Utiliser hash_map plutôt que map s'il n'y a pas besoin de trier. 252

View File

@ -5,38 +5,6 @@ using namespace std ;
/*** Accesseurs lecture ***/
Point3D AccessPoint::get_coordinates() const
{
return coordinates ;
}
unsigned int AccessPoint::get_frequency() const
{
return frequency ;
}
/*** Accesseurs écriture ***/
void AccessPoint::set_coordinates(Point3D &_coordinates)
{
coordinates = _coordinates ;
}
void AccessPoint::set_frequency(unsigned int &_frequency)
{
frequency = _frequency ;
}
/*** Opérateurs ***/
@ -65,12 +33,6 @@ bool AccessPoint::operator==(const AccessPoint &ap) const
}
bool AccessPoint::operator!=(const AccessPoint &ap) const
{
return !(*this == ap) ;
}
ostream &operator<<(ostream &os, const AccessPoint &ap)
{

View File

@ -48,4 +48,48 @@ public:
friend std::ostream &operator<<(std::ostream &os, const AccessPoint &ap) ;
} ;
/*** Accesseurs lecture ***/
inline Point3D AccessPoint::get_coordinates() const
{
return coordinates ;
}
inline unsigned int AccessPoint::get_frequency() const
{
return frequency ;
}
/*** Accesseurs écriture ***/
inline void AccessPoint::set_coordinates(Point3D &_coordinates)
{
coordinates = _coordinates ;
}
inline void AccessPoint::set_frequency(unsigned int &_frequency)
{
frequency = _frequency ;
}
/*** Opérateurs ***/
inline bool AccessPoint::operator!=(const AccessPoint &ap) const
{
return !(*this == ap) ;
}
#endif // _OWLPS_POSITIONING_ACCESSPOINT_HH_

View File

@ -82,96 +82,7 @@ Area::Area(const Area &a)
/*** Accesseurs lecture ***/
Building* Area::get_building(void) const
{
return building ;
}
string Area::get_name() const
{
return name ;
}
Point3D Area::get_p_min() const
{
return p_min ;
}
Point3D Area::get_p_max() const
{
return p_max ;
}
/*** Accesseurs écriture ***/
void Area::set_building(const Building *_building)
{
building = (Building *) _building ;
}
void Area::set_name(const string &_name)
{
name = _name ;
}
void Area::set_x_min(const float &v)
{
p_min.set_x(v) ;
}
void Area::set_y_min(const float &v)
{
p_min.set_y(v) ;
}
void Area::set_z_min(const float &v)
{
p_min.set_z(v) ;
}
void Area::set_x_max(const float &v)
{
p_max.set_x(v) ;
}
void Area::set_y_max(const float &v)
{
p_max.set_y(v) ;
}
void Area::set_z_max(const float &v)
{
p_max.set_z(v) ;
}
void Area::set_p_min(const Point3D &p)
{
p_min = p ;
}
void Area::set_p_max(const Point3D &p)
{
p_max = p ;
}
/*** Opérations ***/
bool Area::contains_point(const Point3D &p) const
@ -187,6 +98,9 @@ bool Area::contains_point(const Point3D &p) const
/*** Opérateurs ***/
bool Area::operator==(const Area &a) const
{
if (this == &a)
@ -200,12 +114,6 @@ bool Area::operator==(const Area &a) const
}
bool Area::operator!=(const Area &a) const
{
return !(*this == a) ;
}
ostream &operator<<(ostream &os, const Area &a)
{

View File

@ -43,9 +43,113 @@ public:
bool contains_point(const Point3D &p) const ;
bool operator==(const Area &a) const ;
inline bool operator!=(const Area &a) const ;
bool operator!=(const Area &a) const ;
friend std::ostream &operator<<(std::ostream &os, const Area &a) ;
} ;
/*** Accesseurs lecture ***/
inline Building* Area::get_building() const
{
return building ;
}
inline std::string Area::get_name() const
{
return name ;
}
inline Point3D Area::get_p_min() const
{
return p_min ;
}
inline Point3D Area::get_p_max() const
{
return p_max ;
}
/*** Accesseurs écriture ***/
inline void Area::set_building(const Building *_building)
{
building = (Building *) _building ;
}
inline void Area::set_name(const std::string &_name)
{
name = _name ;
}
inline void Area::set_x_min(const float &v)
{
p_min.set_x(v) ;
}
inline void Area::set_y_min(const float &v)
{
p_min.set_y(v) ;
}
inline void Area::set_z_min(const float &v)
{
p_min.set_z(v) ;
}
inline void Area::set_x_max(const float &v)
{
p_max.set_x(v) ;
}
inline void Area::set_y_max(const float &v)
{
p_max.set_y(v) ;
}
inline void Area::set_z_max(const float &v)
{
p_max.set_z(v) ;
}
inline void Area::set_p_min(const Point3D &p)
{
p_min = p ;
}
inline void Area::set_p_max(const Point3D &p)
{
p_max = p ;
}
/*** Opérateurs ***/
inline bool Area::operator!=(const Area &a) const
{
return !(*this == a) ;
}
#endif // _OWLPS_POSITIONING_AREA_HH_

View File

@ -51,49 +51,6 @@ Building::~Building()
}
/*** Accesseurs lecture ***/
string Building::get_name() const
{
return name ;
}
vector<Area*> Building::get_areas() const
{
return areas ;
}
vector<Waypoint*> Building::get_waypoints() const
{
return waypoints ;
}
/*** Accesseurs écriture ***/
void Building::set_name(const string &_name)
{
name = _name ;
}
void Building::add_area(const Area *a)
{
areas.push_back((Area *) a) ;
}
void Building::add_waypoint(const Waypoint *wp)
{
waypoints.push_back((Waypoint *) wp) ;
}
/*** Opérateurs ***/
@ -123,12 +80,6 @@ bool Building::operator==(const Building &b) const
}
bool Building::operator!=(const Building &b) const
{
return !(*this == b) ;
}
ostream& operator<<(ostream &os, const Building &b)
{

View File

@ -30,9 +30,65 @@ public :
Building operator=(const Building &p) ;
bool operator==(const Building &p) const ;
inline bool operator!=(const Building &p) const ;
bool operator!=(const Building &p) const ;
friend std::ostream& operator<<(std::ostream &os, const Building &b) ;
} ;
/*** Accesseurs lecture ***/
inline std::string Building::get_name() const
{
return name ;
}
inline std::vector<Area*> Building::get_areas() const
{
return areas ;
}
inline std::vector<Waypoint*> Building::get_waypoints() const
{
return waypoints ;
}
/*** Accesseurs écriture ***/
inline void Building::set_name(const std::string &_name)
{
name = _name ;
}
inline void Building::add_area(const Area *a)
{
areas.push_back((Area *) a) ;
}
inline void Building::add_waypoint(const Waypoint *wp)
{
waypoints.push_back((Waypoint *) wp) ;
}
/*** Opérateurs ***/
inline bool Building::operator!=(const Building &b) const
{
return !(*this == b) ;
}
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_

View File

@ -2,26 +2,6 @@
/*** Accesseurs lecture ***/
ReferencePoint* CalibrationMeasurement::get_reference_point(void) const
{
return reference_point ;
}
/*** Accesseurs écriture ***/
void CalibrationMeasurement::set_reference_point(const ReferencePoint *_rp)
{
reference_point = (ReferencePoint *) _rp ;
}
/*** Opérateurs ***/
@ -49,12 +29,6 @@ bool CalibrationMeasurement::operator==(const CalibrationMeasurement &cm)
}
bool CalibrationMeasurement::operator!=(const CalibrationMeasurement &cm)
{
return !(*this == cm) ;
}
std::ostream &operator<<(std::ostream &os, const CalibrationMeasurement &cm)
{

View File

@ -37,4 +37,37 @@ public:
const CalibrationMeasurement &cm) ;
} ;
/*** Accesseurs lecture ***/
inline ReferencePoint* CalibrationMeasurement::get_reference_point(void) const
{
return reference_point ;
}
/*** Accesseurs écriture ***/
inline void CalibrationMeasurement::set_reference_point(
const ReferencePoint *_rp)
{
reference_point = (ReferencePoint *) _rp ;
}
/*** Opérateurs ***/
inline bool CalibrationMeasurement::operator!=(const CalibrationMeasurement &cm)
{
return !(*this == cm) ;
}
#endif // _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_

View File

@ -34,42 +34,6 @@ Measurement::~Measurement()
/*** Accesseurs lecture ***/
Mobile* Measurement::get_mobile() const
{
return mobile ;
}
AccessPoint* Measurement::get_ap() const
{
return ap ;
}
vector<int> Measurement::get_ss_list() const
{
return ss_list ;
}
float Measurement::get_average_ss() const
{
return average_ss ;
}
/*
float Measurement::get_ss_square_distance(const float &ss) const
{
return ((ss - average_ss) * (ss - average_ss)) ;
}
*/
/*** Accesseurs écriture ***/
@ -87,18 +51,6 @@ void Measurement::update_average_ss()
}
void Measurement::set_mobile(const Mobile *_mobile)
{
mobile = (Mobile *) _mobile ;
}
void Measurement::set_ap(const AccessPoint *_ap)
{
ap = (AccessPoint *) _ap ;
}
void Measurement::add_ss(const int &ss)
{
float ss_mwatts =
@ -140,12 +92,6 @@ bool Measurement::operator==(const Measurement &m)
}
bool Measurement::operator!=(const Measurement &m)
{
return !(*this == m) ;
}
ostream &operator<<(ostream &os, const Measurement &m)
{

View File

@ -43,4 +43,66 @@ public:
friend std::ostream &operator<<(std::ostream &os, const Measurement &m) ;
} ;
/*** Accesseurs lecture ***/
inline Mobile* Measurement::get_mobile() const
{
return mobile ;
}
inline AccessPoint* Measurement::get_ap() const
{
return ap ;
}
inline std::vector<int> Measurement::get_ss_list() const
{
return ss_list ;
}
inline float Measurement::get_average_ss() const
{
return average_ss ;
}
// inline float Measurement::get_ss_square_distance(const float &ss) const
// {
// return ((ss - average_ss) * (ss - average_ss)) ;
// }
/*** Accesseurs écriture ***/
inline void Measurement::set_mobile(const Mobile *_mobile)
{
mobile = (Mobile *) _mobile ;
}
inline void Measurement::set_ap(const AccessPoint *_ap)
{
ap = (AccessPoint *) _ap ;
}
/*** Opérateurs ***/
inline bool Measurement::operator!=(const Measurement &m)
{
return !(*this == m) ;
}
#endif // _OWLPS_POSITIONING_MEASUREMENT_HH_

View File

@ -26,12 +26,6 @@ bool Mobile::operator==(const Mobile &m) const
}
bool Mobile::operator!=(const Mobile &m) const
{
return !(*this == m) ;
}
std::ostream &operator<<(std::ostream &os, const Mobile &m)
{

View File

@ -29,4 +29,16 @@ public:
friend std::ostream &operator<<(std::ostream &os, const Mobile &m) ;
} ;
/*** Opérateurs ***/
inline bool Mobile::operator!=(const Mobile &m) const
{
return !(*this == m) ;
}
#endif // _OWLPS_POSITIONING_MOBILE_HH_

View File

@ -30,61 +30,6 @@ Point3D::Point3D(const float c[3])
/*** Accesseurs lecture ***/
float Point3D::get_x() const
{
return x ;
}
float Point3D::get_y() const
{
return y ;
}
float Point3D::get_z() const
{
return z ;
}
/*** Accesseurs écriture ***/
void Point3D::set_x(const float &_x)
{
x = _x ;
}
void Point3D::set_y(const float &_y)
{
y = _y ;
}
void Point3D::set_z(const float &_z)
{
z = _z ;
}
/*
* Updates x, y, z by passing a Point3D
* This is useful for derivated classes, and different than a direct call to
* operator=().
*/
void Point3D::set_coordinates(const Point3D &p)
{
this->operator=(p) ;
}
/*** Calcul de distances ***/
@ -114,30 +59,6 @@ float Point3D::square_distance(const float &_x,
}
/*
* Distance à un point (Point3D)
* Note : pour comparer deux distances, utiliser de préférence
* square_distance, qui fait économiser une racine carrée.
*/
float Point3D::distance(const Point3D &p) const
{
return sqrt(square_distance(p)) ;
}
/*
* Distance à un point décrit par ses coordonnées
* Note : pour comparer deux distances, utiliser de préférence
* square_distance, qui fait économiser une racine carrée.
*/
float Point3D::distance(const float &_x,
const float &_y,
const float &_z) const
{
return sqrt(square_distance(_x, _y, _z)) ;
}
/*** Opérateurs ***/
@ -167,12 +88,6 @@ bool Point3D::operator==(const Point3D &p) const
}
bool Point3D::operator!=(const Point3D &p) const
{
return !(*this == p) ;
}
bool Point3D::operator<(const Point3D &p) const
{
if (x < p.x)
@ -192,24 +107,6 @@ bool Point3D::operator<(const Point3D &p) const
}
bool Point3D::operator>(const Point3D &p) const
{
return (p < *this) ;
}
bool Point3D::operator<=(const Point3D &p) const
{
return (*this < p || *this == p) ;
}
bool Point3D::operator>=(const Point3D &p) const
{
return (p <= *this) ;
}
std::ostream& operator<<(std::ostream &os, const Point3D &p)
{

View File

@ -28,23 +28,136 @@ public:
void set_coordinates(const Point3D &p) ;
float square_distance(const Point3D &p) const ;
inline float distance(const Point3D &p) const ;
float distance(const Point3D &p) const ;
float square_distance(const float &mx,
const float &my,
const float &mz) const ;
inline float distance(const float &mx,
const float &my,
const float &mz) const ;
float distance(const float &mx,
const float &my,
const float &mz) const ;
Point3D operator=(const Point3D &p) ;
bool operator==(const Point3D &p) const ;
inline bool operator!=(const Point3D &p) const ;
bool operator!=(const Point3D &p) const ;
bool operator<(const Point3D &p) const ;
inline bool operator>(const Point3D &p) const ;
bool operator>(const Point3D &p) const ;
bool operator<=(const Point3D &p) const ;
inline bool operator>=(const Point3D &p) const ;
bool operator>=(const Point3D &p) const ;
friend std::ostream& operator<<(std::ostream &os, const Point3D &p) ;
} ;
/*** Accesseurs lecture ***/
inline float Point3D::get_x() const
{
return x ;
}
inline float Point3D::get_y() const
{
return y ;
}
inline float Point3D::get_z() const
{
return z ;
}
/*** Accesseurs écriture ***/
inline void Point3D::set_x(const float &_x)
{
x = _x ;
}
inline void Point3D::set_y(const float &_y)
{
y = _y ;
}
inline void Point3D::set_z(const float &_z)
{
z = _z ;
}
/*
* Updates x, y, z by passing a Point3D
* This is useful for derivated classes, and different than a direct
* call to operator=().
*/
inline void Point3D::set_coordinates(const Point3D &p)
{
this->operator=(p) ;
}
/*** Calcul de distances ***/
/*
* Distance à un point (Point3D)
* Note : pour comparer deux distances, utiliser de préférence
* square_distance, qui fait économiser une racine carrée.
*/
inline float Point3D::distance(const Point3D &p) const
{
return sqrt(square_distance(p)) ;
}
/*
* Distance à un point décrit par ses coordonnées
* Note : pour comparer deux distances, utiliser de préférence
* square_distance, qui fait économiser une racine carrée.
*/
inline float Point3D::distance(const float &_x,
const float &_y,
const float &_z) const
{
return sqrt(square_distance(_x, _y, _z)) ;
}
/*** Opérateurs ***/
inline bool Point3D::operator!=(const Point3D &p) const
{
return !(*this == p) ;
}
inline bool Point3D::operator>(const Point3D &p) const
{
return (p < *this) ;
}
inline bool Point3D::operator<=(const Point3D &p) const
{
return (*this < p || *this == p) ;
}
inline bool Point3D::operator>=(const Point3D &p) const
{
return (p <= *this) ;
}
#endif // _OWLPS_POSITIONING_POINT3D_HH_

View File

@ -15,26 +15,6 @@ ReferencePoint::~ReferencePoint()
/*** Accesseurs lecture ***/
vector<CalibrationMeasurement*> ReferencePoint::get_measurements() const
{
return measurements ;
}
/*** Accesseurs écriture ***/
void ReferencePoint::add_measurement(const CalibrationMeasurement *cm)
{
measurements.push_back((CalibrationMeasurement *) cm) ;
}
// float ReferencePoint::getSsSquareDistance(const vector<CalibrationMeasurement> &m) const
// {
// unsigned int i, j;
@ -168,12 +148,6 @@ bool ReferencePoint::operator==(const ReferencePoint &rp) const
}
bool ReferencePoint::operator!=(const ReferencePoint &rp) const
{
return !(*this == rp) ;
}
ostream &operator<<(ostream &os, const ReferencePoint &rp)
{

View File

@ -34,4 +34,37 @@ public:
friend std::ostream &operator<<(std::ostream &os, const ReferencePoint &rp) ;
} ;
/*** Accesseurs lecture ***/
inline
std::vector<CalibrationMeasurement*> ReferencePoint::get_measurements() const
{
return measurements ;
}
/*** Accesseurs écriture ***/
inline void ReferencePoint::add_measurement(const CalibrationMeasurement *cm)
{
measurements.push_back((CalibrationMeasurement *) cm) ;
}
/*** Opérateurs ***/
inline bool ReferencePoint::operator!=(const ReferencePoint &rp) const
{
return !(*this == rp) ;
}
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_

View File

@ -29,39 +29,6 @@ Waypoint::~Waypoint()
/*** Accesseurs lecture ***/
Building* Waypoint::get_1st_building() const
{
try
{
return buildings.at(0) ;
}
catch (out_of_range &e)
{
return NULL ;
}
}
vector<Building*> Waypoint::get_buildings() const
{
return buildings ;
}
/*** Accesseurs écriture ***/
void Waypoint::add_building(const Building *_b)
{
buildings.push_back((Building *) _b) ;
}
/*** Opérateurs ***/
@ -88,12 +55,6 @@ bool Waypoint::operator==(const Waypoint &wp) const
}
bool Waypoint::operator!=(const Waypoint &wp) const
{
return !(*this == wp) ;
}
ostream &operator<<(ostream &os, const Waypoint &wp)
{

View File

@ -29,9 +29,54 @@ public:
Waypoint operator=(const Waypoint &wp) ;
bool operator==(const Waypoint &wp) const ;
inline bool operator!=(const Waypoint &wp) const ;
bool operator!=(const Waypoint &wp) const ;
friend std::ostream& operator<<(std::ostream &os, const Waypoint &wp) ;
} ;
/*** Accesseurs lecture ***/
inline Building* Waypoint::get_1st_building() const
{
try
{
return buildings.at(0) ;
}
catch (std::out_of_range &e)
{
return NULL ;
}
}
inline std::vector<Building*> Waypoint::get_buildings() const
{
return buildings ;
}
/*** Accesseurs écriture ***/
inline void Waypoint::add_building(const Building *_b)
{
buildings.push_back((Building *) _b) ;
}
/*** Opérateurs ***/
inline bool Waypoint::operator!=(const Waypoint &wp) const
{
return !(*this == wp) ;
}
#endif // _OWLPS_POSITIONING_WAYPOINT_HH_

View File

@ -30,62 +30,6 @@ WifiDevice::WifiDevice(const WifiDevice &wd)
/*** Accesseurs lecture ***/
string WifiDevice::get_ip_addr() const
{
return ip_addr ;
}
string WifiDevice::get_mac_addr() const
{
return mac_addr ;
}
float WifiDevice::get_antenna_gain() const
{
return antenna_gain ;
}
float WifiDevice::get_trx_power() const
{
return trx_power ;
}
/*** Accesseurs écriture ***/
void WifiDevice::set_ip_addr(const string &_ip_addr)
{
ip_addr = _ip_addr ;
}
void WifiDevice::set_mac_addr(const string &_mac_addr)
{
mac_addr = _mac_addr ;
}
void WifiDevice::set_antenna_gain(float &_antenna_gain)
{
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
}
void WifiDevice::set_trx_power(float &_trx_power)
{
trx_power = _trx_power ;
}
/*** Opérateurs ***/
@ -116,12 +60,6 @@ bool WifiDevice::operator==(const WifiDevice &wd) const
}
bool WifiDevice::operator!=(const WifiDevice &wd) const
{
return !(*this == wd) ;
}
ostream &operator<<(ostream &os, const WifiDevice &wd)
{

View File

@ -42,4 +42,72 @@ public:
friend std::ostream &operator<<(std::ostream &os, const WifiDevice &wd) ;
} ;
/*** Accesseurs lecture ***/
inline std::string WifiDevice::get_ip_addr() const
{
return ip_addr ;
}
inline std::string WifiDevice::get_mac_addr() const
{
return mac_addr ;
}
inline float WifiDevice::get_antenna_gain() const
{
return antenna_gain ;
}
inline float WifiDevice::get_trx_power() const
{
return trx_power ;
}
/*** Accesseurs écriture ***/
inline void WifiDevice::set_ip_addr(const std::string &_ip_addr)
{
ip_addr = _ip_addr ;
}
inline void WifiDevice::set_mac_addr(const std::string &_mac_addr)
{
mac_addr = _mac_addr ;
}
inline void WifiDevice::set_antenna_gain(float &_antenna_gain)
{
antenna_gain = PosUtil::channel_to_frequency(_antenna_gain) ;
}
inline void WifiDevice::set_trx_power(float &_trx_power)
{
trx_power = _trx_power ;
}
/*** Opérateurs ***/
inline bool WifiDevice::operator!=(const WifiDevice &wd) const
{
return !(*this == wd) ;
}
#endif // _OWLPS_POSITIONING_WIFIDEVICE_HH_