[Positioner] Make Building::areas const
This commit is contained in:
parent
ea01f09b5e
commit
5520541217
|
@ -75,7 +75,7 @@ void Building::add_area(Area *&area)
|
|||
return ;
|
||||
}
|
||||
|
||||
areas[area_name] = const_cast<Area*>(area) ;
|
||||
areas[area_name] = area ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Building
|
|||
protected:
|
||||
std::string name ;
|
||||
/// List of Area contained in the Building
|
||||
std::unordered_map<std::string, Area*> areas ;
|
||||
std::unordered_map<std::string, const Area*> areas ;
|
||||
/// List of Waypoint in the Building
|
||||
std::unordered_set<Waypoint*> waypoints ;
|
||||
|
||||
|
@ -46,7 +46,8 @@ public:
|
|||
/** @name Read accessors */
|
||||
//@{
|
||||
const std::string& get_name(void) const ;
|
||||
const std::unordered_map<std::string, Area*>& get_areas(void) const ;
|
||||
const std::unordered_map<std::string, const Area*>&
|
||||
get_areas(void) const ;
|
||||
const std::unordered_set<Waypoint*>& get_waypoints(void) const ;
|
||||
//@}
|
||||
|
||||
|
@ -81,7 +82,7 @@ inline const std::string& Building::get_name() const
|
|||
}
|
||||
|
||||
|
||||
inline const std::unordered_map<std::string, Area*>&
|
||||
inline const std::unordered_map<std::string, const Area*>&
|
||||
Building::get_areas() const
|
||||
{
|
||||
return areas ;
|
||||
|
|
|
@ -100,7 +100,8 @@ const Area* Stock::in_which_area_is(const Point3D &point)
|
|||
{
|
||||
for (auto b = buildings.begin() ; b != buildings.end() ; ++b)
|
||||
{
|
||||
const unordered_map<string, Area*> &areas = b->second.get_areas() ;
|
||||
const unordered_map<string, const Area*> &areas =
|
||||
b->second.get_areas() ;
|
||||
for (auto a = areas.begin() ; a != areas.end() ; ++a)
|
||||
if (a->second->contains_point(point))
|
||||
return a->second ;
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
// Simple read accessors
|
||||
Building b1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_name(), "Unnamed building") ;
|
||||
std::unordered_map<std::string, Area*> areas1 ;
|
||||
std::unordered_map<std::string, const Area*> areas1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_areas(), areas1) ;
|
||||
std::unordered_set<Waypoint*> waypoints1 ;
|
||||
TS_ASSERT_EQUALS(b1.get_waypoints(), waypoints1) ;
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
TS_ASSERT_EQUALS(building1->get_areas().size(), 2u) ;
|
||||
|
||||
Area *area_ptr ;
|
||||
const Area *area_ptr ;
|
||||
area_ptr = building1->get_areas().find("My room #1")->second ;
|
||||
Area area1(building1, "My room #1",
|
||||
Point3D(1,2,3), Point3D(9,8,7)) ;
|
||||
|
|
Loading…
Reference in New Issue