Linkgraph: Refactoring to avoid manual deletes.

pull/11/head
Jonathan G Rennison 7 years ago
parent 28211c21fc
commit 2080daab8d

@ -212,12 +212,12 @@ void LinkGraphSchedule::ShiftDates(int interval)
*/ */
LinkGraphSchedule::LinkGraphSchedule() LinkGraphSchedule::LinkGraphSchedule()
{ {
this->handlers[0] = new InitHandler; this->handlers[0].reset(new InitHandler);
this->handlers[1] = new DemandHandler; this->handlers[1].reset(new DemandHandler);
this->handlers[2] = new MCFHandler<MCF1stPass>; this->handlers[2].reset(new MCFHandler<MCF1stPass>);
this->handlers[3] = new FlowMapper(false); this->handlers[3].reset(new FlowMapper(false));
this->handlers[4] = new MCFHandler<MCF2ndPass>; this->handlers[4].reset(new MCFHandler<MCF2ndPass>);
this->handlers[5] = new FlowMapper(true); this->handlers[5].reset(new FlowMapper(true));
} }
/** /**
@ -226,9 +226,6 @@ LinkGraphSchedule::LinkGraphSchedule()
LinkGraphSchedule::~LinkGraphSchedule() LinkGraphSchedule::~LinkGraphSchedule()
{ {
this->Clear(); this->Clear();
for (uint i = 0; i < lengthof(this->handlers); ++i) {
delete this->handlers[i];
}
} }
LinkGraphJobGroup::LinkGraphJobGroup(constructor_token token, std::vector<LinkGraphJob *> jobs) : LinkGraphJobGroup::LinkGraphJobGroup(constructor_token token, std::vector<LinkGraphJob *> jobs) :

@ -46,7 +46,7 @@ private:
friend const SaveLoad *GetLinkGraphScheduleDesc(); friend const SaveLoad *GetLinkGraphScheduleDesc();
protected: protected:
ComponentHandler *handlers[6]; ///< Handlers to be run for each job. std::unique_ptr<ComponentHandler> handlers[6]; ///< Handlers to be run for each job.
GraphList schedule; ///< Queue for new jobs. GraphList schedule; ///< Queue for new jobs.
JobList running; ///< Currently running jobs. JobList running; ///< Currently running jobs.

Loading…
Cancel
Save