classdef (Hidden) ModelWrapper < handle & matlab.mixin.Copyable & ...
        matlab.mixin.SetGet
    % Data class for models in app workspace

    % Author(s): S. Gumussoy, A. Ouellette
    % Copyright 2015-2023 The MathWorks, Inc.

    properties (SetObservable)        
        Name % Label for model browser        
        System % LTI system
        SparseFreqVector = []
        SparseTimeVector = []
    end
    properties(Hidden,Dependent)
        %% Backwards compatibility
        Label
        LTI
    end
    events
        ValueChanged
    end
    methods
        %% Constructor
        function this = ModelWrapper(name, sys)
            this.Name = name;
            this.System = sys;
        end
        %% Get/set
        function set.System(this, sys)
            this.System = sys;
            notify(this, 'ValueChanged');
        end
        function freq = get.SparseFreqVector(this)
            if issparse(this.System)
                freq = this.SparseFreqVector;
            else
                freq = [];
            end
        end
        function set.SparseFreqVector(this,freq)
            if issparse(this.System) %#ok<MCSUP>
                this.SparseFreqVector = freq;
            end
        end
        function time = get.SparseTimeVector(this)
            if issparse(this.System)
                time = this.SparseTimeVector;
            else
                time = [];
            end
        end
        function set.SparseTimeVector(this,time)
            if issparse(this.System) %#ok<MCSUP>
                this.SparseTimeVector = time;
            end
        end
        %% Backwards compatibility
        function sys = get.LTI(this)
            sys = this.System;
        end
        function set.LTI(this,sys)
            this.System = sys;
        end
        function name = get.Label(this)
            name = this.Name;
        end
        function set.Label(this,name)
            this.Name = name;
        end
    end
end