function schema
%SCHEMA   Define the hdlcc class.

%   Author(s): P. Costa, Jie Sun
%   Copyright 2005-2022 The MathWorks, Inc.
%     

% store persistent variables
mlock;

pk = findpackage('hdlcoderui');
parentcls = findclass(findpackage('Simulink'), 'CustomCC');

% From the Simulink.ConfigSetDemo demo
c  = schema.class(pk, 'hdlcc', parentcls);

if hdlcoderui.isslhdlcinstalled
    % Store a handle to the HDLCoder object (driver) as an API between the UI
    % and the HDLCoder infrastructure. This is a property which
    % will be serialized to the .MDL file.
    p = schema.prop(c, 'HDLCoder','mxArray');
    p.AccessFlags.PublicSet = 'off';
    p.AccessFlags.Serialize = 'off';
    set(p,'Visible','off');
    
    % Holds an array of objects representing each "plug-in" subcomponent in the
    % HDL Coder Configuration Component (e.g., EDA Scripts, Test Bench, etc).
    p = schema.prop(c, 'SubComponents', 'mxArray');
    p.AccessFlags.PublicSet = 'off';
    % p.AccessFlags.PublicGet = 'off';
    p.AccessFlags.Serialize = 'off';
    set(p,'Visible','off');

    % Add a property to store currently selected block for "remove" listener to use
    p = schema.prop(c,'currentSelectedBlock','string');
    p.AccessFlags.PublicSet = 'on';
    p.AccessFlags.PublicGet = 'on';
    set(p,'FactoryValue','','Visible','off');
    p.AccessFlags.Serialize = 'off';
    
    p = schema.prop(c,'HDLCodeGenStatus','string');
    p.AccessFlags.PublicSet = 'on';
    p.AccessFlags.PublicGet = 'on';
    p.AccessFlags.Serialize = 'off';
    set(p, 'FactoryValue', 'Idle', 'Visible', 'off');
    
    % The flag for changes made but not applied to CLI yet
    p = schema.prop(c,'HDLPresetFlag','bool');
    p.AccessFlags.PublicSet = 'on';
    p.AccessFlags.PublicGet = 'on';
    p.AccessFlags.Serialize = 'off';
    set(p,'FactoryValue', false, 'Visible','off');
    
    % The flag for changes made and applied to CLI
    p = schema.prop(c,'HDLSetFlag','bool');
    p.AccessFlags.PublicSet = 'on';
    p.AccessFlags.PublicGet = 'on';
    p.AccessFlags.Serialize = 'off';
    set(p,'FactoryValue', false, 'Visible','off');
    
    % Flag to remember the previous path info
    p = schema.prop(c,'LastPath','string');
    p.AccessFlags.PublicSet = 'on';
    p.AccessFlags.PublicGet = 'on';
    p.AccessFlags.Serialize = 'off';
    set(p, 'Visible','off');
    
    % Add a property to store the required listeners.  We need a property
    % so that a reference to the listener is maintained.  Thus keeping
    % the listener active.  However, we do not want the Listener to be
    % visible or saved.  Therefore, set the AccessFlags such that PublicSet
    % PublicGet and Serialize are set to off.
    lp = schema.prop(c, 'HDLListener', 'mxArray');
    lp.AccessFlags.Serialize = 'off';
    set(lp,'Visible','off');
    
    lp = schema.prop(c, 'NameChangeListener', 'mxArray');
    lp.AccessFlags.PublicSet = 'on';
    lp.AccessFlags.PublicGet = 'on';
    lp.AccessFlags.Serialize = 'off';
    set(lp,'Visible','off');
end

% Store the path to the Configuration File; This is a property which
% will be serialized to the .MDL file.
p = schema.prop(c,'HDLConfigFile','mxArray');
set(p,'FactoryValue',{' '}, 'Visible', 'off');
set(p, 'SetFunction', @set_HDLConfigFile);
    
% Property required to manage the tab in a tabbed container that is to be
% selected when the dialog opens.  This property is required here so that
% the tabs behave properly in the ME. This is a property which
% will be serialized to the .MDL file.
p = schema.prop(c, 'HDLCActiveTab', 'int');
set(p,'FactoryValue',0,'Visible','off');
    
p = schema.prop(c,'CLI','mxArray');
p.AccessFlags.PublicSet = 'on';
p.AccessFlags.PublicGet = 'on';
p.AccessFlags.Serialize = 'off';
set(p, 'Visible','off');

p = schema.prop(c,'DownstreamIntegrationDriver','mxArray');
p.AccessFlags.PublicSet = 'off';
p.AccessFlags.PublicGet = 'off';
p.AccessFlags.Serialize = 'off';
set(p, 'Visible','off');

p = schema.prop(c,'hdlinstalled','bool');
p.AccessFlags.PublicSet = 'on';
p.AccessFlags.PublicGet = 'on';
set(p,'Visible','off');
p.AccessFlags.Serialize = 'off';

p = schema.prop(c,'fListener','mxArray');
p.AccessFlags.PublicSet = 'off';
p.AccessFlags.PublicGet = 'off';
set(p,'Visible','off');
p.AccessFlags.Serialize = 'off';

%
% Methods
%
m = schema.method(c, 'getName');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {'string'};

m = schema.method(c, 'dialogCallback');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle', 'handle', 'string', 'string'};
s.OutputTypes = {};

m = schema.method(c, 'update');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle', 'string'};
s.OutputTypes = {};

m = schema.method(c, 'isVisible');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {'bool'};

m = schema.method(c, 'updateDialog');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {};

m = schema.method(c, 'getDisplayLabel');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {'ustring'};

m = schema.method(c, 'hasDialogEverOpened');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle', 'bool'};
s.OutputTypes = {'bool'};

m = schema.method(c, 'getAllParamValueStatusForDialog');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {'mxArray'};

m = schema.method(c, 'setupListener');
s = m.Signature;
s.varargin = 'off';
s.InputTypes = {'handle'};
s.OutputTypes = {};

end

%--------------------------------------------------------------------
function valueOut = set_HDLConfigFile(this, value) %#ok
if ~iscell(value)
    error(message('HDLShared:hdlcoderui:notCellArray'));
else
    for ix=1:numel(value)
        if ~isempty(value{ix}) && ~ischar(value{ix})
            error(message('HDLShared:hdlcoderui:notString'));
        end
    end
end

valueOut = value;
end
