2010-01-11 19:40:45 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_REQUEST_HH_
|
|
|
|
#define _OWLPS_POSITIONING_REQUEST_HH_
|
|
|
|
|
|
|
|
class Mobile ;
|
|
|
|
|
|
|
|
#include "measurement.hh"
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <ostream>
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Represents a request sent by a Mobile
|
2010-01-11 19:40:45 +01:00
|
|
|
class Request
|
|
|
|
{
|
|
|
|
protected:
|
2010-01-16 12:23:07 +01:00
|
|
|
/// The mobile that sent the request
|
2010-01-11 19:40:45 +01:00
|
|
|
Mobile *mobile ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Local date of the request on the mobile
|
2010-01-11 19:40:45 +01:00
|
|
|
struct timespec timestamp ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// List of Measurement of the request
|
|
|
|
/** Note that this is not a pointer list, values are actually stored. */
|
2010-01-11 19:40:45 +01:00
|
|
|
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
|
|
|
|
|
|
|
public:
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Constructs a Request from a list of Measurement (or default constructor)
|
2010-01-11 19:40:45 +01:00
|
|
|
Request(const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
|
|
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Constructs a Request from a timestamp and (possibly) a Measurement list
|
2010-01-11 19:40:45 +01:00
|
|
|
Request(const struct timespec &_timestamp,
|
|
|
|
const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
|
|
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// \brief Constructs a request from a mobile and a timestamp and (possibly)
|
|
|
|
/// a Measurement list
|
2010-01-11 19:40:45 +01:00
|
|
|
Request(const Mobile *_mobile, const struct timespec &_timestamp,
|
|
|
|
const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
|
|
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
~Request(void) ; ///< Destructor
|
|
|
|
|
|
|
|
/** @name Read accessors */
|
|
|
|
//@{
|
|
|
|
/// #mobile read accessor
|
2010-01-13 15:29:44 +01:00
|
|
|
Mobile* get_mobile(void) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// #timestamp read accessor
|
|
|
|
const struct timespec& get_timestamp(void) const ;
|
|
|
|
//@}
|
2010-01-11 19:40:45 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Write accessors */
|
|
|
|
//@{
|
|
|
|
/// #mobile write accessor
|
2010-01-11 19:40:45 +01:00
|
|
|
void set_mobile(const Mobile *_mobile) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// #timestamp write accessor
|
2010-01-11 19:40:45 +01:00
|
|
|
void set_timestamp(const struct timespec &_timestamp) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// #measurements write accessor
|
2010-01-11 19:40:45 +01:00
|
|
|
void set_measurements(const std::tr1::unordered_map
|
|
|
|
<std::string, Measurement> &_measurements) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Reinitialises all attributes
|
2010-01-11 19:40:45 +01:00
|
|
|
void clear(void) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2010-01-11 19:40:45 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Operators */
|
|
|
|
//@{
|
|
|
|
operator bool(void) const ; ///< Cast to bool operator
|
|
|
|
//@}
|
2010-01-11 19:40:45 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Displays a Request
|
2010-01-11 19:40:45 +01:00
|
|
|
friend std::ostream &operator<<(std::ostream &os, const Request &r) ;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Read accessors *** */
|
2010-01-11 19:40:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
inline Mobile* Request::get_mobile() const
|
|
|
|
{
|
|
|
|
return mobile ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
inline const struct timespec& Request::get_timestamp() const
|
|
|
|
{
|
|
|
|
return timestamp ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 19:40:45 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Write accessors *** */
|
2010-01-11 19:40:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
inline void Request::set_mobile(const Mobile *_mobile)
|
|
|
|
{
|
2010-01-18 14:19:57 +01:00
|
|
|
mobile = const_cast<Mobile*>(_mobile) ;
|
2010-01-11 19:40:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void Request::set_timestamp(const struct timespec &_timestamp)
|
|
|
|
{
|
|
|
|
timestamp = _timestamp ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void Request::set_measurements(const std::tr1::unordered_map
|
|
|
|
<std::string, Measurement> &_measurements)
|
|
|
|
{
|
|
|
|
measurements = _measurements ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operators *** */
|
2010-01-11 19:40:45 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
|
|
|
* @return \em false if the Request is empty.
|
|
|
|
* @return \em true if at least one attribute is initialised.
|
2010-01-11 19:40:45 +01:00
|
|
|
*/
|
|
|
|
inline Request::operator bool() const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
mobile != NULL ||
|
|
|
|
timestamp.tv_sec != 0 ||
|
|
|
|
measurements.size() > 0 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_REQUEST_HH_
|