#ifndef _OWLPS_POSITIONING_REQUEST_HH_ #define _OWLPS_POSITIONING_REQUEST_HH_ class Mobile ; #include "measurement.hh" #include "timestamp.hh" #include #include #include #include /// Represents a request sent by a Mobile class Request { protected: /// Type of the request uint_fast8_t type ; /// The mobile that sent the request Mobile *mobile ; /// Local date of the request on the mobile Timestamp time_sent ; /// 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 AP. */ std::tr1::unordered_map measurements ; public: Request(const Mobile *_mobile = NULL, const Timestamp &_time_sent = Timestamp(), const std::tr1::unordered_map &_measurements = std::tr1::unordered_map()): type(OWL_REQUEST_UNDEFINED), mobile(const_cast(_mobile)), time_sent(_time_sent), measurements(_measurements) {} Request(const std::tr1::unordered_map &_measurements): type(OWL_REQUEST_UNDEFINED), mobile(NULL), measurements(_measurements) {} Request(const Timestamp &_time_sent, const std::tr1::unordered_map &_measurements = std::tr1::unordered_map()): type(OWL_REQUEST_UNDEFINED), mobile(NULL), time_sent(_time_sent), measurements(_measurements) {} Request(const Request &source): type(source.type), mobile(source.mobile), time_sent(source.time_sent), measurements(source.measurements) {} virtual ~Request(void) ; /** @name Read accessors */ //@{ uint8_t get_type(void) const ; Mobile* get_mobile(void) const ; const Timestamp& get_time_sent(void) const ; const std::tr1::unordered_map& get_measurements(void) const ; //@} /** @name Write accessors */ //@{ void set_type(const uint8_t _type) ; void set_mobile(const Mobile *_mobile) ; void set_time_sent(const Timestamp &_time_sent) ; void set_measurements(const std::tr1::unordered_map &_measurements) ; void clear(void) ; //@} /** @name Operators */ //@{ const Request& operator=(const Request &source) ; bool operator==(const Request &comp) const ; bool operator!=(const Request &comp) const ; operator bool(void) const ; //@} /// Displays a Request friend std::ostream& operator<<(std::ostream &os, const Request &r) ; /// Hash a Request friend std::size_t hash_value(const Request &source) ; } ; /* *** Read accessors *** */ inline uint8_t Request::get_type() const { return type ; } inline Mobile* Request::get_mobile() const { return mobile ; } inline const Timestamp& Request::get_time_sent() const { return time_sent ; } inline const std::tr1::unordered_map& Request::get_measurements(void) const { return measurements ; } /* *** Write accessors *** */ inline void Request::set_type(const uint8_t _type) { type = _type ; } inline void Request::set_mobile(const Mobile *_mobile) { mobile = const_cast(_mobile) ; } inline void Request::set_time_sent(const Timestamp &_time_sent) { time_sent = _time_sent ; } inline void Request:: set_measurements(const std::tr1::unordered_map &_measurements) { measurements = _measurements ; } /* *** Operators *** */ inline bool Request::operator!=(const Request &comp) const { return !(*this == comp) ; } /** * @return \em false if the Request is empty. * @return \em true if at least one attribute is initialised. */ inline Request::operator bool() const { return mobile != NULL || time_sent || measurements.size() > 0 ; } #endif // _OWLPS_POSITIONING_REQUEST_HH_