classdef ModelBlockPortDimensionsWriter < coder.internal.modelreference.PortDimensionsWriter
%MODELBLOCKPORTDIMENSIONSWRITER - writes PortMatrixDimensions, 
%PortDimensionInfo and PortVectorDimension information in 
%mdlInitializeSizes of the SIL/PIL SFunction

%   Copyright 2019 The MathWorks, Inc.
    
    methods(Access = public)
        function this = ModelBlockPortDimensionsWriter(modelInterface, writer)
            % call super class constructor
            this@coder.internal.modelreference.PortDimensionsWriter(modelInterface, writer);
        end
        
    end
    
    methods(Access = protected)
        function [numDims, dims, width] = getSymbDimensionsInfo(this, port, portCodeInfo)
            if isempty(portCodeInfo) || isempty(portCodeInfo.Type) || ...
                ~(portCodeInfo.Type.isMatrix && portCodeInfo.Type.HasSymbolicDimensions)
                % call super class
                [numDims, dims, width] = getSymbDimensionsInfo@...
                    coder.internal.modelreference.PortDimensionsWriter(this, port, portCodeInfo);
            else
                portDT = portCodeInfo.Type;
                dims = rtw.connectivity.CodeInfoUtils.getArray(portDT.SymbolicDimensions);
                numDims = length(dims);
                width = portDT.SymbolicWidth;
            end
        end
    end
end
