package fabrik.simulator.pic16f84;

import fabrik.simulator.pic16f84.interfaces.*;

import java.util.HashMap;

public class PICComponents {
    private final HashMap<Class<? extends PICComponentInterface>, PICComponentInterface> componentCatalogue;

    public PICComponents() {
        super();
        this.componentCatalogue = new HashMap<>();
    }

    public void registerComponent (Class<? extends PICComponentInterface> componentClass, PICComponentInterface component) {
        this.componentCatalogue.put(componentClass, component);
    }

    public PICComponentInterface getComponent(Class<? extends PICComponentInterface> componentClass) {
        return this.componentCatalogue.get(componentClass);
    }

    public void initAll() {
        for (PICComponentInterface component : componentCatalogue.values()) component.initialize(this);
    }

}
