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 getDerivationUnit(int index) {
		return units.get(index);
	}
	
	public int getDerivationUnitCount() {
		return units.size();
	}
	
	public DerivationResults nextDerivation(DerivationUnit unit, MethodProperty property) {
		return unit.nextDerivation(property);
	}
	
	public HashSet<DerivationResults> getResults() {
		return results;
	}
	
	public HashSet<DerivationResults> firstDerivation() {
		for (DerivationUnit unit : units) {
//			HashSet<InferenceResults> irs = unit.firstInference();
//			for (InferenceResults ir : irs) {
//				results.add(ir);
//			}
			results.add(unit.firstDerivation());
		}
		return results;
	}

}
