[Positioner] Test pointers as booleans
This commit is contained in:
parent
ec8c1244cd
commit
92db007d6b
|
@ -61,7 +61,7 @@ Building::~Building()
|
|||
*/
|
||||
void Building::add_area(const Area *const area)
|
||||
{
|
||||
if (area == NULL)
|
||||
if (!area)
|
||||
return ;
|
||||
|
||||
string area_name = area->get_name() ;
|
||||
|
|
|
@ -112,7 +112,7 @@ inline void Building::set_name(const std::string &_name)
|
|||
*/
|
||||
inline void Building::add_waypoint(Waypoint *const wp)
|
||||
{
|
||||
if (wp != NULL)
|
||||
if (wp)
|
||||
waypoints.insert(wp) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
|
||||
PosUtil::hash_combine(seed, static_cast<Request>(source)) ;
|
||||
PosUtil::hash_combine(seed, source.get_direction()) ;
|
||||
if (source.get_reference_point() != NULL)
|
||||
if (source.get_reference_point())
|
||||
PosUtil::hash_combine(seed, *source.get_reference_point()) ;
|
||||
|
||||
return seed ;
|
||||
|
|
|
@ -147,7 +147,7 @@ const Request& Input::get_next_request() const
|
|||
/* If the request is a calibration request, add it to the Stock */
|
||||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(const_cast<Request*>(&request)) ;
|
||||
if (calibration_request != NULL)
|
||||
if (calibration_request)
|
||||
{
|
||||
if (Configuration::bool_value(
|
||||
"positioning.accept-new-calibration-requests"))
|
||||
|
@ -183,7 +183,7 @@ const Request& Input::get_next_request() const
|
|||
|
||||
bool Input::eof() const
|
||||
{
|
||||
if (medium == NULL)
|
||||
if (!medium)
|
||||
throw null_input_medium() ;
|
||||
return medium->eof() ;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ void InputDataReader::read_from_reference_points_media()
|
|||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(
|
||||
const_cast<Request*>(&request)) ;
|
||||
if (calibration_request == NULL)
|
||||
if (!calibration_request)
|
||||
cerr << "Warning! Invalid calibration request at line "
|
||||
<< (*i)->get_current_line_nb() << endl ;
|
||||
else
|
||||
|
|
|
@ -73,7 +73,7 @@ const Request& InputMedium::get_next_request()
|
|||
|
||||
void InputMedium::clear_current_request()
|
||||
{
|
||||
if (dynamic_cast<CalibrationRequest*>(current_request) == NULL)
|
||||
if (! dynamic_cast<CalibrationRequest*>(current_request))
|
||||
current_request->clear() ;
|
||||
else
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ void InputMedium::current_request_to_calibration_request(
|
|||
{
|
||||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(current_request) ;
|
||||
if (calibration_request != NULL)
|
||||
if (calibration_request)
|
||||
{
|
||||
calibration_request->set_reference_point(
|
||||
const_cast<ReferencePoint*>(reference_point)) ;
|
||||
|
|
|
@ -241,7 +241,7 @@ inline bool Measurement::operator!=(const Measurement &m) const
|
|||
inline Measurement::operator bool() const
|
||||
{
|
||||
return
|
||||
cp != NULL ||
|
||||
cp ||
|
||||
! ss_list.empty() ;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ int OutputTCPSocketEvAAL::
|
|||
area_of_interest_number(const Point3D &position) const
|
||||
{
|
||||
const Area *const area = Stock::in_which_area_is(position) ;
|
||||
if (area == NULL)
|
||||
if (!area)
|
||||
return 0 ;
|
||||
|
||||
int aoi_number = 0 ;
|
||||
|
|
|
@ -25,7 +25,7 @@ Result RealPosition::compute(const Request &request)
|
|||
const CalibrationRequest *calibration_request =
|
||||
dynamic_cast<const CalibrationRequest*>(&request) ;
|
||||
|
||||
if (calibration_request != NULL)
|
||||
if (calibration_request)
|
||||
coordinates = static_cast<Point3D*>(
|
||||
calibration_request->get_reference_point()) ;
|
||||
else
|
||||
|
|
|
@ -163,7 +163,7 @@ bool ReferencePoint::delete_generated_requests(void)
|
|||
assert(*r) ;
|
||||
unordered_map<std::string, CapturePoint>::const_iterator cp ;
|
||||
|
||||
if ((*r)->get_mobile() == NULL)
|
||||
if (! (*r)->get_mobile())
|
||||
goto delete_request ;
|
||||
|
||||
// Check if the request was sent by a CP
|
||||
|
|
|
@ -131,7 +131,7 @@ std::vector<CalibrationRequest*>& ReferencePoint::get_requests() const
|
|||
*/
|
||||
inline void ReferencePoint::add_request(const CalibrationRequest *r)
|
||||
{
|
||||
if (r != NULL)
|
||||
if (r)
|
||||
requests.push_back(const_cast<CalibrationRequest*>(r)) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ const string Request::to_csv() const
|
|||
|
||||
csv_line << aggregation_csv_format << ';' ;
|
||||
|
||||
if (mobile != NULL)
|
||||
if (mobile)
|
||||
csv_line << mobile->get_mac_addr() ;
|
||||
|
||||
csv_line
|
||||
|
@ -230,7 +230,7 @@ const string Request::to_csv() const
|
|||
|
||||
const CalibrationRequest *calibration_request =
|
||||
dynamic_cast<const CalibrationRequest*>(this) ;
|
||||
if (calibration_request == NULL)
|
||||
if (!calibration_request)
|
||||
csv_line << "0;0;0;0" ;
|
||||
else
|
||||
{
|
||||
|
@ -262,7 +262,7 @@ ostream& operator<<(ostream &os, const Request &r)
|
|||
os << "Type: " << static_cast<uint_fast16_t>(r.type)
|
||||
<< ", Number of packets sent: " << r.nb_packets
|
||||
<< ", Mobile: "
|
||||
<< (r.mobile != NULL ? r.mobile->get_mac_addr() : "Unknown_Mobile")
|
||||
<< (r.mobile ? r.mobile->get_mac_addr() : "Unknown_Mobile")
|
||||
<< ":" ;
|
||||
|
||||
// List of Measurements
|
||||
|
|
|
@ -245,7 +245,7 @@ inline bool Request::operator!=(const Request &comp) const
|
|||
inline Request::operator bool() const
|
||||
{
|
||||
return
|
||||
mobile != NULL ||
|
||||
mobile ||
|
||||
time_sent ||
|
||||
! measurements.empty() ;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ Result::Result(const Request *const _request,
|
|||
string Result::in_which_area() const
|
||||
{
|
||||
const Area *area = Stock::in_which_area_is(position) ;
|
||||
if (area == NULL)
|
||||
if (!area)
|
||||
return "" ;
|
||||
|
||||
return area->get_name() ;
|
||||
|
@ -118,7 +118,7 @@ const string Result::to_csv() const
|
|||
<< ';' ;
|
||||
|
||||
const Area *const area = Stock::in_which_area_is(position) ;
|
||||
if (area != NULL)
|
||||
if (area)
|
||||
csv_line << area->get_name() ;
|
||||
|
||||
return csv_line.str() ;
|
||||
|
|
|
@ -89,9 +89,9 @@ const string ResultList::to_csv() const
|
|||
{
|
||||
ostringstream csv_line ;
|
||||
|
||||
if (request != NULL)
|
||||
if (request)
|
||||
{
|
||||
if (request->get_mobile() != NULL)
|
||||
if (request->get_mobile())
|
||||
csv_line << request->get_mobile()->get_mac_addr() ;
|
||||
csv_line
|
||||
<< ';' << static_cast<uint_fast16_t>(request->get_type())
|
||||
|
@ -110,7 +110,7 @@ const string ResultList::to_csv() const
|
|||
|
||||
ostream& operator<<(ostream &os, const ResultList &r)
|
||||
{
|
||||
if (r.request == NULL)
|
||||
if (!r.request)
|
||||
os << "For an unknown request:\n" ;
|
||||
else
|
||||
os << "For the following request: " << *(r.request) << '\n' ;
|
||||
|
|
|
@ -138,7 +138,7 @@ void Stock::waypoint_remove_building(const Waypoint &point,
|
|||
|
||||
// If the Waypoint is not linked to any Building any more, we
|
||||
// delete it
|
||||
if (waypoint->get_1st_building() == NULL)
|
||||
if (! waypoint->get_1st_building())
|
||||
waypoints.erase(i) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ void TestUtil::create_request_list()
|
|||
|
||||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(requests.at(1)) ;
|
||||
if (calibration_request != NULL)
|
||||
if (calibration_request)
|
||||
calibration_request->reference_point_backward_link() ;
|
||||
|
||||
requests.push_back(new Request(&mobiles[0], timestamps[2],
|
||||
|
@ -162,7 +162,7 @@ void TestUtil::create_result_list()
|
|||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(*i) ;
|
||||
Result result ;
|
||||
if (calibration_request != NULL)
|
||||
if (calibration_request)
|
||||
result = algo.compute(*calibration_request) ;
|
||||
else
|
||||
result = algo.compute(**i) ;
|
||||
|
@ -350,9 +350,9 @@ bool TestUtil::request_equals(const Request &first,
|
|||
return false ;
|
||||
|
||||
// Compare mobile values
|
||||
if (first.get_mobile() == NULL || second.get_mobile() == NULL)
|
||||
if (! (first.get_mobile() && second.get_mobile()))
|
||||
{
|
||||
if (first.get_mobile() != NULL || second.get_mobile() != NULL)
|
||||
if (first.get_mobile() || second.get_mobile())
|
||||
return false ;
|
||||
}
|
||||
else if (*first.get_mobile() != *second.get_mobile())
|
||||
|
@ -406,9 +406,9 @@ bool TestUtil::measurement_equals(const Measurement &first,
|
|||
return false ;
|
||||
|
||||
// Compare ap values
|
||||
if (first.get_cp() == NULL || second.get_cp() == NULL)
|
||||
if (! (first.get_cp() && second.get_cp()))
|
||||
{
|
||||
if (first.get_cp() != NULL || second.get_cp() != NULL)
|
||||
if (first.get_cp() || second.get_cp())
|
||||
return false ;
|
||||
}
|
||||
else if (*first.get_cp() != *second.get_cp())
|
||||
|
|
|
@ -35,7 +35,7 @@ Waypoint::Waypoint(Building *const _b,
|
|||
const float _x, const float _y, const float _z):
|
||||
Point3D(_x, _y, _z)
|
||||
{
|
||||
if (_b != NULL)
|
||||
if (_b)
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ Waypoint::Waypoint(Building *const _b,
|
|||
*/
|
||||
Waypoint::Waypoint(Building *const _b, const Point3D &p): Point3D(p)
|
||||
{
|
||||
if (_b != NULL)
|
||||
if (_b)
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ Waypoint::get_buildings() const
|
|||
*/
|
||||
inline void Waypoint::add_building(Building *const _b)
|
||||
{
|
||||
if (_b != NULL)
|
||||
if (_b)
|
||||
buildings.insert(_b) ;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ inline void Waypoint::add_buildings(const Waypoint &source)
|
|||
|
||||
inline void Waypoint::remove_building(Building *const _b)
|
||||
{
|
||||
if (_b != NULL)
|
||||
if (_b)
|
||||
buildings.erase(_b) ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue