package interactivefeaturelocator.model;

import java.util.ArrayList;
import java.util.HashSet;

import org.ntlab.trace.MethodExecution;

public class DerivationManager {
	private ArrayList<DerivationUnit> units = new ArrayList<>();
	private HashSet<DerivationResults> results = new HashSet<>();
	
	public DerivationManager(Feature feature) {
		for (Pattern pattern : feature.getPatterns()) {
			units.add(new DerivationUnit(pattern));
		}
	}
	
	public DerivationUnit getInferenceUnit(int index) {
		return units.get(index);
	}
	
	public int getInferenceUnitCount() {
		return units.size();
	}
	
	public DerivationResults nextInference(DerivationUnit unit, MethodProperty property) {
		return unit.nextInference(property);
	}
	
	public HashSet<DerivationResults> getResults() {
		return results;
	}
	
	public HashSet<DerivationResults> firstInference() {
		for (DerivationUnit unit : units) {
//			HashSet<InferenceResults> irs = unit.firstInference();
//			for (InferenceResults ir : irs) {
//				results.add(ir);
//			}
			results.add(unit.firstInference());
		}
		return results;
	}

}
