package fabrik.simulator.pic16f84;

import java.util.HashSet;
import java.util.Set;

import fabrik.simulator.pic16f84.interfaces.ExecutionTimeObserver;
import fabrik.simulator.pic16f84.interfaces.PICComponentInterface;

public abstract class ExecutionTimeSubject extends PICComponent implements PICComponentInterface{
    private Set<ExecutionTimeObserver> observers;
    
    public ExecutionTimeSubject(){
        super();
        this.observers = new HashSet<>();
    }


    public void registerObserver(ExecutionTimeObserver observer){
        observers.add(observer);
    }

    public void unregisterObserver(ExecutionTimeObserver observer){
        observers.remove(observer);
    }

    protected void notifyObservers(){
            observers.forEach(o -> o.executionTimeChanged());
        }
        
    public double getTotalExecutionTime(){
        throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
    }
    
    public void addExecutionTime(int i){
        throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
    }

    public double getExecutionTimeMultiplier(){
        throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
    }

    public void setExecutionTimeMultiplier(String option){
        throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
    }
    
    public void resetTotalExecutionTime(){
        throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
    }

    @Override
    public void initialize(PICComponentLocator locator) {
        super.initialize(locator);
    }
}
