classdef RunContext < bioinfo.pipeline.internal.VersionMixin
    %RUNCONTEXT class to hold all Runtime settings for Bioinformatics Pipeline objects
    %
    % RunContext properties:
    % UseParallel       - Logical to specify if the pipeline will be run in parallel mode
    % DisplayLevel      - LogLevel (0-4) value specifying the which messages will be output to the command window
    % SkipUnmodified    - Logical specifying whether the pipeline will run blocks that have not been modified since the last run
    % ResultsDirectory  - String specifying a folder where the pipeline run results will be written
    % RunMode           - Enum specifying make-like behavior.
    % 
    % RunContext hidden properties:
    % InputStruct       - Struct specifying Input port name values

    properties
        UseParallel(1,1) logical = false

        DisplayLevel(1,1) bioinfo.pipeline.LogLevel = 2

        RunMode(1,1) bioinfo.pipeline.RunMode = "Minimal"

        ResultsDirectory(1,1) string {mustBeNonzeroLengthText} = "PipelineResults"

        % Vector of block IDs
        SaveResults {bioinfo.pipeline.internal.Validation.mustBeBlockID(SaveResults)} = "-all";

        AbsoluteResultsDirectory(1,1) string = ""; % Resolved in Pipeline.run()
    end

    properties (Hidden)
        % InputStruct is an optional positional input argument (not NVP) to Pipeline.run. 
        InputStruct(1,1) struct = struct()
    end


    methods
        function obj = RunContext(pipelineRunArgs)
            arguments
                pipelineRunArgs(1,1) struct = struct();
            end

            % Assign matching args to this run context
            matchingProperties = intersect(fieldnames(pipelineRunArgs), properties(obj));
            for rcProp = 1:numel(matchingProperties)
                obj.(matchingProperties{rcProp}) = pipelineRunArgs.(matchingProperties{rcProp});
            end

        end

    end
end