package org.implab.gradle.variants.sources;

import org.gradle.api.Action;
import org.implab.gradle.common.sources.GenericSourceSet;
import org.implab.gradle.variants.core.Layer;
import org.implab.gradle.variants.core.Variant;
import org.implab.gradle.variants.core.VariantsView;

/**
 * Registry of symbolic source set names produced by sources projection.
 *
 * Identity in this registry is the GenericSourceSet name.
 */
public interface VariantSourcesContext {

   /**
     * Finalized core model.
     */
    VariantsView getVariants();

    /**
     * Derived compile-side view.
     */
    CompileUnitsView getCompileUnits();

    /**
     * Derived role-side view.
     */
    RoleProjectionsView getRoleProjections();

    /**
     * Lazy source set provider service.
     */
    SourceSetMaterializer getSourceSets();

    /**
     * Configures all GenericSourceSets produced from the given layer.
     *
     * The action is applied:
     * - to already materialized source sets of this layer
     * - to all future source sets of this layer
     *
     * Actions are applied in registration order.
     */
    void configureLayer(Layer layer, Action<? super GenericSourceSet> action);

    void configureVariant(Variant variant, Action<? super GenericSourceSet> action);

    void configureUnit(CompileUnit unit, Action<? super GenericSourceSet> action);

}