#include "stdafx.h"
#include "SimulationControllerFacade.h"


void SimulationControllerFacade::attachUIObserver(AbstractUIObserver* observer)
{
	theObservers->push_back(observer);
}

void SimulationControllerFacade::detachUIObserver(AbstractUIObserver* observer)
{
	theObservers->remove(observer);
}

void SimulationControllerFacade::notifyStep(){
	list<AbstractUIObserver*> observers = *theObservers;
	while(observers.size() >0){
		AbstractUIObserver* element = observers.front();
		element->setSimulationResultDTO(getSimulationResult());
		element->updateStep();
		observers.pop_front();
	}
}

void SimulationControllerFacade::notifySimulation(){
	list<AbstractUIObserver*> observers = *theObservers;
	while(observers.size() >0){
		AbstractUIObserver* element = observers.front();
		element->setSimulationResultDTO(getSimulationResult());
		element->updateSimulation();
		observers.pop_front();
	}
}

void SimulationControllerFacade::notifyMultipleSimulations(){
	list<AbstractUIObserver*> observers = *theObservers;
	while(observers.size() >0){
		AbstractUIObserver* element = observers.front();
		element->setSimulationResultDTO(getSimulationResult());
		element->updateMultipleSimulations();
		observers.pop_front();
	}
}
