classdef Output < bioinfo.pipeline.internal.SemanticModelObject
    
    
    properties (SetAccess = immutable)
        % REQUIRED Logical scalar that indicates whether the output port is a
        % required output of the block. A required output must be a field
        % of the struct returned by the run method of a block, or the block
        % will fail in a pipeline. The default is true.
        Required(1,1) logical
    end
    
    properties
        % UniformOutput Logical scalar that indicates whether parallel
        % run outputs should not be merged with cell arrays. This setting
        % determines the merge strategy if a block has inputs with parallel
        % dimensions. If true (the default), the result from each parallel
        % run are merged according to the output data type and concatenated
        % along the parallel dimensions. Additionally, when UniformOutput
        % is true, the individual outputs from each run must be scalar,
        % unless the block only runs once. If there is no parallelism or
        % only one parallel run call, non-scalars are allowed with
        % UniformOutput set to true. If false, the results from each run
        % are wrapped in a cell array before concatenating.
        %
        % Example:
        %
        % p = bioinfo.pipeline.Pipeline;
        % SB = p.addBlock(bioinfo.pipeline.blocks.UserFunction(@numel, "N", "A"));
        % SB.Inputs.A.SplitDimension = 1;
        % inputStruct.A = [ 1 2 3; 4 5 6];
        %
        % % Merge the results from each parallel run and return an array
        % p.run(inputStruct);
        % results(p, SB).N
        % 
        % % Merge the results from each parallel run wrapped in a cell array
        % SB.Outputs.N.UniformOutput = false;
        % p.run(inputStruct);
        % results(p, SB).N
        %  
        %
        % See also bioinfo.pipeline.Input.ParallelDimensions,
        % bioinfo.pipeline.Pipeline.run
        UniformOutput(1,1) logical = true;
    end
    
    methods
        function obj = Output(NVPArgs)
            % OUTPUT Create bioinfo.pipeline.Output object.
            %
            % OP = OUTPUT(NAME) constructs an output object with the given name.
            %
            % OP = OUTPUT(..., 'Required', tf) indicates whether the port is a
            %      required output of the block.  A required output must be
            %      a field of the struct returned by the run method of the
            %      block, or the block will fail in a pipeline. The
            %      default is true.
            %
            % See also Required, bioinfo.pipeline.Block
            arguments
                NVPArgs.Required(1,1) logical = true
            end
            
            obj.Required = NVPArgs.Required;
        end
    end
end
% Copyright 2020-2022 The MathWorks, Inc.

