[Positioning] ReferencePoint::delete_generated_requests()
This commit is contained in:
parent
6c48bc7e29
commit
232551c150
|
@ -117,9 +117,9 @@ void ReferencePoint::delete_requests()
|
||||||
int stock_nb_requests = Stock::nb_calibration_requests() ;
|
int stock_nb_requests = Stock::nb_calibration_requests() ;
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
for (vector<CalibrationRequest*>::iterator i = requests.begin() ;
|
for (vector<CalibrationRequest*>::iterator r = requests.begin() ;
|
||||||
i != requests.end() ; ++i)
|
r != requests.end() ; ++r)
|
||||||
Stock::delete_calibration_request(**i) ;
|
Stock::delete_calibration_request(**r) ;
|
||||||
|
|
||||||
assert(Stock::nb_calibration_requests() ==
|
assert(Stock::nb_calibration_requests() ==
|
||||||
stock_nb_requests - requests.size()) ;
|
stock_nb_requests - requests.size()) ;
|
||||||
|
@ -128,6 +128,46 @@ void ReferencePoint::delete_requests()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that the requests pointed by the elements of #requests are
|
||||||
|
* actually deleted from the Stock.
|
||||||
|
* @returns \em true if at least one request was deleted.
|
||||||
|
* @returns \em false if the ReferencePoint was left untouched.
|
||||||
|
*/
|
||||||
|
bool ReferencePoint::delete_generated_requests(void)
|
||||||
|
{
|
||||||
|
bool modified = false ;
|
||||||
|
|
||||||
|
for (vector<CalibrationRequest*>::iterator r = requests.begin() ;
|
||||||
|
r != requests.end() ; ++r)
|
||||||
|
{
|
||||||
|
assert(*r) ;
|
||||||
|
if ((*r)->get_mobile() == NULL)
|
||||||
|
{
|
||||||
|
requests.erase(r) ;
|
||||||
|
modified = true ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
|
||||||
|
unordered_map<std::string, AccessPoint>::const_iterator ap ;
|
||||||
|
for (ap = Stock::get_aps().begin() ; ap != Stock::get_aps().end() ;
|
||||||
|
++ap)
|
||||||
|
if ((*r)->get_mobile()->get_mac_addr() ==
|
||||||
|
ap->second.get_mac_addr())
|
||||||
|
break ;
|
||||||
|
|
||||||
|
if (ap == Stock::get_aps().end()) // r is not associated with an AP
|
||||||
|
{
|
||||||
|
Stock::delete_calibration_request(**r) ;
|
||||||
|
requests.erase(r) ;
|
||||||
|
modified = true ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return modified ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Operations *** */
|
/* *** Operations *** */
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
void add_request(const CalibrationRequest *cm) ;
|
void add_request(const CalibrationRequest *cm) ;
|
||||||
/// Deletes all the requests contained in #requests
|
/// Deletes all the requests contained in #requests
|
||||||
void delete_requests(void) ;
|
void delete_requests(void) ;
|
||||||
|
/// Deletes the requests that are not sent by an AP
|
||||||
|
bool delete_generated_requests(void) ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Operations */
|
/** @name Operations */
|
||||||
|
|
Loading…
Reference in New Issue