classdef BuildInfoFile < RTW.BuildInfoClass
%RTW.BuildInfoFile class
%   RTW.BuildInfoFile extends RTW.BuildInfoClass.
%

%   Copyright 2017-2023 The MathWorks, Inc.

    properties
        FileName = '';
        Path = '';
    end

    properties(Hidden)
        IsPreinclude = false;
    end

    methods
        function h = BuildInfoFile(fileName, path, group, displayLabel, isPreinclude)
            arguments
                fileName {mustBeTextScalar} = '';
                path  {mustBeTextScalar} = '';
                group {mustBeTextScalar} = '';
                displayLabel  {mustBeTextScalar} = 'BuildInfo file';
                isPreinclude (1,1) logical = false;
            end

            %  when the object is read in from a mat file, this is called with no args to
            %  load the class
            if nargin == 0
                return;
            end

            % Instantiate class
            % override the base class display label. This is not displayed in the
            % DAStudioExplorer, since we want the filename listed instead.  It's
            % being set here for debugging purposes to differentiate the different
            % BuildInfoObjects.
            h.FileName     = convertStringsToChars(fileName);
            h.Path         = convertStringsToChars(path);
            h.Group        = convertStringsToChars(group);
            h.DisplayLabel = convertStringsToChars(displayLabel);
            h.IsPreinclude = isPreinclude;
        end
    end

    methods
        
        function val = getDisplayLabel(h)
        %GETDISPLAYLABEL - Returns the display label for DAStudio Explorer.  
            val = char(h.FileName);
        end
        
        function val = getPreferredProperties(h)
        %GETPREFERREDPROPERTIES - Returns the preferred properties for the DA Studio
        %Explorer
        % the base class has properties which should be in the
        % preferred properties list.  Since there is no way to call a
        % base class method from a derived class, call a surrogate
        % getPreferredProperties from the base class.
            base_props = h.getBaseBuildInfoClassProperties();
            additional_props = {'Path'};
            val = [base_props additional_props];
        end
        
        function val = isHierarchical(~)
        %ISHIERARCHICAL - returns true if this class has hierarchical child properties.
            val = true;
        end
    end
end

