[Positioning] Add Request::real_position
This commit is contained in:
parent
1bb589b460
commit
00bbc9c49d
|
@ -22,6 +22,25 @@ Request::~Request()
|
|||
/* *** Write accessors *** */
|
||||
|
||||
|
||||
inline void Request::clear_real_position()
|
||||
{
|
||||
if (real_position)
|
||||
{
|
||||
delete real_position ;
|
||||
real_position = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Request::set_real_position(const Point3D &_real_position)
|
||||
{
|
||||
if (real_position)
|
||||
*real_position = _real_position ;
|
||||
else
|
||||
real_position = new Point3D(_real_position) ;
|
||||
}
|
||||
|
||||
|
||||
/// Reinitialises all attributes
|
||||
/**
|
||||
* - #mobile is NULLified, but the value it pointed to is not deleted.
|
||||
|
@ -34,6 +53,7 @@ void Request::clear()
|
|||
mobile = NULL ;
|
||||
time_sent.clear() ;
|
||||
measurements.clear() ;
|
||||
clear_real_position() ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +71,10 @@ const Request& Request::operator=(const Request &source)
|
|||
time_sent = source.time_sent ;
|
||||
measurements = source.measurements ;
|
||||
|
||||
clear_real_position() ;
|
||||
if (source.real_position)
|
||||
real_position = new Point3D(*source.real_position) ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
@ -60,7 +84,13 @@ bool Request::operator==(const Request &source) const
|
|||
if (this == &source)
|
||||
return true ;
|
||||
|
||||
bool real_position_equal =
|
||||
real_position &&
|
||||
source.real_position &&
|
||||
*real_position == *source.real_position ;
|
||||
|
||||
return
|
||||
real_position_equal &&
|
||||
type == source.type &&
|
||||
mobile == source.mobile &&
|
||||
time_sent == source.time_sent &&
|
||||
|
@ -72,8 +102,10 @@ bool Request::operator==(const Request &source) const
|
|||
ostream& operator<<(ostream &os, const Request &r)
|
||||
{
|
||||
// Timestamp
|
||||
os
|
||||
<< "At " << r.time_sent << "; " ;
|
||||
os << "At " << r.time_sent << "; " ;
|
||||
|
||||
if (r.real_position)
|
||||
os << " Real coordinates : " << *r.real_position << "; " ;
|
||||
|
||||
// MAC address
|
||||
os
|
||||
|
@ -88,9 +120,7 @@ ostream& operator<<(ostream &os, const Request &r)
|
|||
else
|
||||
for (unordered_map<string, Measurement>::const_iterator i
|
||||
= r.measurements.begin() ; i != r.measurements.end() ; ++i)
|
||||
{
|
||||
os << '\n' << i->first << ": " << i->second ;
|
||||
}
|
||||
os << '\n' << i->first << ": " << i->second ;
|
||||
|
||||
return os ;
|
||||
}
|
||||
|
@ -107,8 +137,10 @@ size_t hash_value(const Request &source)
|
|||
|
||||
boost::hash_combine(seed, source.type) ;
|
||||
boost::hash_combine(seed, source.time_sent) ;
|
||||
if (source.mobile != NULL)
|
||||
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 ;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ protected:
|
|||
/** Note that this is not a pointer list, values are actually stored.
|
||||
The \em string parameter is the MAC address of the AP. */
|
||||
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||
/// \brief Real coordinates of the request (normally unavailable for a
|
||||
/// standard positioning request)
|
||||
Point3D *real_position ;
|
||||
|
||||
void clear_real_position(void) ;
|
||||
|
||||
public:
|
||||
Request(const Mobile *_mobile = NULL,
|
||||
|
@ -35,12 +40,12 @@ public:
|
|||
std::tr1::unordered_map<std::string, Measurement>()):
|
||||
type(OWL_REQUEST_UNDEFINED),
|
||||
mobile(const_cast<Mobile*>(_mobile)), time_sent(_time_sent),
|
||||
measurements(_measurements) {}
|
||||
measurements(_measurements), real_position(NULL) {}
|
||||
|
||||
Request(const std::tr1::unordered_map<std::string, Measurement>
|
||||
&_measurements):
|
||||
type(OWL_REQUEST_UNDEFINED),
|
||||
mobile(NULL), measurements(_measurements) {}
|
||||
mobile(NULL), measurements(_measurements), real_position(NULL) {}
|
||||
|
||||
Request(const Timestamp &_time_sent,
|
||||
const std::tr1::unordered_map<std::string, Measurement>
|
||||
|
@ -48,12 +53,12 @@ public:
|
|||
std::tr1::unordered_map<std::string, Measurement>()):
|
||||
type(OWL_REQUEST_UNDEFINED),
|
||||
mobile(NULL), time_sent(_time_sent),
|
||||
measurements(_measurements) {}
|
||||
measurements(_measurements), real_position(NULL) {}
|
||||
|
||||
Request(const Request &source):
|
||||
type(source.type),
|
||||
mobile(source.mobile), time_sent(source.time_sent),
|
||||
measurements(source.measurements) {}
|
||||
measurements(source.measurements), real_position(NULL) {}
|
||||
|
||||
virtual ~Request(void) ;
|
||||
|
||||
|
@ -64,6 +69,7 @@ public:
|
|||
const Timestamp& get_time_sent(void) const ;
|
||||
const std::tr1::unordered_map<std::string, Measurement>&
|
||||
get_measurements(void) const ;
|
||||
const Point3D* get_real_position(void) const ;
|
||||
//@}
|
||||
|
||||
/** @name Write accessors */
|
||||
|
@ -73,6 +79,7 @@ public:
|
|||
void set_time_sent(const Timestamp &_time_sent) ;
|
||||
void set_measurements(const std::tr1::unordered_map
|
||||
<std::string, Measurement> &_measurements) ;
|
||||
void set_real_position(const Point3D &_real_position) ;
|
||||
void clear(void) ;
|
||||
//@}
|
||||
|
||||
|
@ -122,6 +129,12 @@ Request::get_measurements(void) const
|
|||
}
|
||||
|
||||
|
||||
inline const Point3D* Request::get_real_position(void) const
|
||||
{
|
||||
return real_position ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Write accessors *** */
|
||||
|
||||
|
|
Loading…
Reference in New Issue