Commit 1a74d107 authored by Ulrich Kemloh's avatar Ulrich Kemloh

fixed few memory leaks in eventmanager

parent cfccfc21
......@@ -92,6 +92,8 @@ EventManager::~EventManager()
{
if(_file)
fclose(_file);
_eventEngineStorage.clear();
}
bool EventManager::ReadEventsXml()
......@@ -143,9 +145,6 @@ bool EventManager::ReadEventsXml()
_updateFrequency = xmltoi(xEvents->ToElement()->Attribute("update_time"), 1);
_updateRadius = xmltoi(xEvents->ToElement()->Attribute("update_radius"), 2);
//string color=xmltoa(xEvents->ToElement()->Attribute("agents_color_by_knowledge"), "false");
//if(color=="true")
// Pedestrian::SetColorMode(BY_KNOWLEDGE);
//Pedestrian::SetColorMode(BY_SPOTLIGHT);
for (TiXmlElement* e = xEvents->FirstChildElement("event"); e;
......@@ -674,6 +673,7 @@ Router * EventManager::CreateRouter(const RoutingStrategy& strategy)
default:
Log->Write("ERROR: \twrong value for routing strategy [%d]!!!\n", strategy );
exit(EXIT_FAILURE);
break;
}
......
......@@ -747,7 +747,7 @@ Room* Building::GetRoom(string caption) const
exit(EXIT_FAILURE);
}
void Building::AddCrossing(Crossing* line)
bool Building::AddCrossing(Crossing* line)
{
if (_crossings.count(line->GetID()) != 0) {
char tmp[CLENGTH];
......@@ -758,9 +758,10 @@ void Building::AddCrossing(Crossing* line)
exit(EXIT_FAILURE);
}
_crossings[line->GetID()] = line;
return true;
}
void Building::AddTransition(Transition* line)
bool Building::AddTransition(Transition* line)
{
if (_transitions.count(line->GetID()) != 0) {
char tmp[CLENGTH];
......@@ -771,16 +772,17 @@ void Building::AddTransition(Transition* line)
exit(EXIT_FAILURE);
}
_transitions[line->GetID()] = line;
return true;
}
void Building::AddHline(Hline* line)
bool Building::AddHline(Hline* line)
{
if (_hLines.count(line->GetID()) != 0) {
// check if the lines are identical
Hline* ori= _hLines[line->GetID()];
if(ori->operator ==(*line)) {
Log->Write("INFO: \tSkipping identical hlines with ID [%d]",line->GetID());
return;
return false;
} else {
Log->Write(
"ERROR: Duplicate index for hlines found [%d] in Routing::AddHline(). You have [%d] hlines",
......@@ -789,9 +791,10 @@ void Building::AddHline(Hline* line)
}
}
_hLines[line->GetID()] = line;
return true;
}
void Building::AddGoal(Goal* goal)
bool Building::AddGoal(Goal* goal)
{
if (_goals.count(goal->GetId()) != 0) {
Log->Write(
......@@ -800,6 +803,7 @@ void Building::AddGoal(Goal* goal)
exit(EXIT_FAILURE);
}
_goals[goal->GetId()] = goal;
return true;
}
const map<int, Crossing*>& Building::GetAllCrossings() const
......
......@@ -170,10 +170,10 @@ public:
const std::map<int, Hline*>& GetAllHlines() const;
const std::map<int, Goal*>& GetAllGoals() const;
void AddCrossing(Crossing* line);
void AddTransition(Transition* line);
void AddHline(Hline* line);
void AddGoal(Goal* goal);
bool AddCrossing(Crossing* line);
bool AddTransition(Transition* line);
bool AddHline(Hline* line);
bool AddGoal(Goal* goal);
const std::string& GetProjectRootDir() const;
const std::string& GetProjectFilename() const;
......
......@@ -175,16 +175,18 @@ void SubRoom::AddGoalID(int ID)
_goalIDs.push_back(ID);
}
void SubRoom::AddCrossing(Crossing* line)
bool SubRoom::AddCrossing(Crossing* line)
{
_crossings.push_back(line);
_goalIDs.push_back(line->GetUniqueID());
return true;
}
void SubRoom::AddTransition(Transition* line)
bool SubRoom::AddTransition(Transition* line)
{
_transitions.push_back(line);
_goalIDs.push_back(line->GetUniqueID());
return true;
}
void SubRoom::AddNeighbor(SubRoom* sub)
......@@ -195,19 +197,20 @@ void SubRoom::AddNeighbor(SubRoom* sub)
}
}
void SubRoom::AddHline(Hline* line)
bool SubRoom::AddHline(Hline* line)
{
for(unsigned int i=0;i<_hlines.size();i++)
{
if (line->GetID()==_hlines[i]->GetID())
{
Log->Write("INFO:\tskipping duplicate hline [%d] with id [%d]",_id,line->GetID());
return;
return false;
}
}
_hlines.push_back(line);
_goalIDs.push_back(line->GetUniqueID());
return true;
}
const vector<Crossing*>& SubRoom::GetAllCrossings() const
......
......@@ -261,9 +261,9 @@ public:
//navigation
void AddCrossing(Crossing* line);
void AddTransition(Transition* line);
void AddHline(Hline* line);
bool AddCrossing(Crossing* line);
bool AddTransition(Transition* line);
bool AddHline(Hline* line);
void AddNeighbor(SubRoom* sub);
const std::vector<Crossing*>& GetAllCrossings() const;
......
......@@ -1477,8 +1477,15 @@ bool GlobalRouter::LoadRoutingInfos(const std::string &filename)
h->SetRoom1(room);
h->SetSubRoom1(subroom);
_building->AddHline(h);
subroom->AddHline(h);
if(_building->AddHline(h))
{
subroom->AddHline(h);
//h will be freed in building
}
else
{
delete h;
}
}
}
Log->Write("INFO:\tDone with loading extra routing information");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment