classdef ExecutionOrderRange < handle
    % Holds on to Execution Order
    
    % Copyright 2018 The MathWorks, Inc.
    
    properties (SetAccess = private, GetAccess = public)
        MaxSubsystemOrder = 0 % largest subsystem order number
        MaxBlockOrder = 0 % largest block order number in any subsystem
    end
    
    properties(SetAccess = private, GetAccess = public)
        isSet = false;
    end
    
    methods
        function this = ExecutionOrderRange(maxSubsystemOrder, maxBlockOrder)
            if nargin == 2
                this.MaxSubsystemOrder = maxSubsystemOrder;
                this.MaxBlockOrder = maxBlockOrder;
                % change the isSet flag to true
                this.isSet = true;
            end
        end
        
        function setRanges(this, allEO)
            % allEO is a cell array of all Execution orders for all results
            for idx = 1:numel(allEO)
                rawExecutionOrder = allEO{idx};
                [subsystemOrder, blockOrder] = fxptui.splitExecutionOrder(rawExecutionOrder);
                
                % ex. '0:1' - subOrder == 0
                % compare against current max and set larger of two
                this.MaxSubsystemOrder = max(this.MaxSubsystemOrder, subsystemOrder);
                
                % ex. '0:1' - blockOrder == 1
                % compare against current max and set larger of two
                this.MaxBlockOrder = max(this.MaxBlockOrder, blockOrder);
                
            end
            
            % change the isSet flag to true
            this.isSet = true;
            
        end
    end
    
    
end
