classdef PortID < modelpack.VariableID
    %modelpack.PortID class
    %   modelpack.PortID extends modelpack.VariableID.
    %

    %    modelpack.PortID properties:
    %       Description - Property is of type 'ustring'
    %
    %    modelpack.PortID methods:
    %       getAliases - Returns the aliases for the individual elements of the port
    %       getType - Returns the I/O type of the port identified by THIS.
    %       isSame - Default implementation for determining whether a given PortID
    %       setAliases - Sets the aliases for the individual elements of the port
    %       setType - Sets the I/O type of the port identified by THIS.

    % Copyright 2000-2023 The MathWorks, Inc.

    methods  % public methods
        function aliases = getAliases(this)
            % GETALIASES Returns the aliases for the individual elements of the port
            % identified by THIS.  For unnamed ports, an empty string should be returned
            % in the cell array.
            %
            % ALIASES is a cell array of strings (cell array of cell arrays if THIS is an
            % object array).  The list of aliases is a flat list whose length matches the
            % total number of signals associated with this port.

            n = numel(this);

            if n == 1
                aliases = {};
            else
                aliases = cell(n,1);
                aliases(:) = {{}};
            end

            warning(message('Controllib:general:AbstractMethodMustBeOverloaded'));

        end  % getAliases

        function type = getType(this)
            % GETTYPE Returns the I/O type of the port identified by THIS.
            %
            % TYPE is an enumerated string of type Model_IOType: 'Input' or 'Output'
            % (cell array of strings if THIS is an object array).

            n = numel(this);

            if n == 1
                type = '';
            else
                type = cell(n,1);
                type(:) = {''};
            end

            warning(message('Controllib:general:AbstractMethodMustBeOverloaded'));

        end  % getType

        function flag = isSame(this, ID)
            % ISSAME Default implementation for determining whether a given PortID
            % object identifies the same object as THIS.  Equivalent to operator
            % overloading for "==".

            flag = false;

            if (length(this(:)) == length(ID(:))) && ...
                    isa(ID, class(this)) && ...
                    all( strcmp(ID.getFullName, this.getFullName) ) && ...
                    isequal(ID.getDimensions, this.getDimensions) && ...
                    all( strcmp(ID.getType, this.getType) )
                flag = true;
            end

        end  % isSame

        function setAliases(~, ~)
            % SETALIASES Sets the aliases for the individual elements of the port
            % identified by THIS.
            %
            % ALIASES is a cell array of strings.  A single string can be used to assign
            % the same alias to each element (signal).

            warning(message('Controllib:general:AbstractMethodMustBeOverloaded'));

        end  % setAliases

        function setType(~, ~)
            % SETTYPE Sets the I/O type of the port identified by THIS.
            %
            % TYPE is an enumerated string of type Model_IOType: 'Input' or 'Output'.

            warning(message('Controllib:general:AbstractMethodMustBeOverloaded'));

        end  % setType

    end  % public methods

end  % classdef

% LocalWords:  GETALIASES SETALIASES
