classdef (Hidden = true) SIAdaptor < rtw.connectivity.CIAdaptor
    % SIAdaptor - Adaptor class from coder.descriptor.SubsystemInterface to
    % coder.descriptor.ComponentInterface
    %
    %   This is an undocumented class. Its methods and properties are likely to
    %   change without warning from one release to the next.
    
    %   Copyright 2019-2020 The MathWorks, Inc.
    
    properties(Access = private)
        SubsystemInterface;
    end
    
    properties(Access = public)
        UsesNonFiniteUtils (1,1) logical
    end
 
    methods(Access = public)
        function this = SIAdaptor(aComponentInterface)
            this = this@rtw.connectivity.CIAdaptor(aComponentInterface);
            
        end
    end
    
    
    methods(Access = protected)
        function populateAdaptor(this)
            assert(this.CodeDescObj.Subsystems.Size == 1, ...
                'Unexpected number of SubsystemInterfaces');
            % assign the SubsystemInterface
            this.SubsystemInterface = this.CodeDescObj.Subsystems(1);
            
            this.UsesNonFiniteUtils = this.SubsystemInterface.UsesNonFiniteUtils;
            
            % use function interface adapters to make custom Getters
            % available for the function interface properties
            this.populateFunctionsArray('InitializeFunctions', this.SubsystemInterface);
            this.populateFunctionsArray('OutputFunctions', this.SubsystemInterface);
            this.populateFunctionsArray('TerminateFunctions', this.SubsystemInterface);
            this.populateFunctionsArray('UpdateFunctions', this.SubsystemInterface);
            this.populateFunctionsArray('EnableFunction', this.SubsystemInterface);
            this.populateFunctionsArray('DisableFunction', this.SubsystemInterface);
            
            this.SetupRuntimeResourcesFunction = this.createFunctionInterfaceAdaptor(...
                this.SubsystemInterface.SetupRuntimeResourcesFunction);
            
            this.SetupRuntimeResourcesFunction = this.createFunctionInterfaceAdaptor(...
                this.SubsystemInterface.CleanupRuntimeResourcesFunction);
            
            % do not expose function interfaces from the ComponentInterface
            this.AllocationFunction = rtw.connectivity.SlFIAdaptor.empty;
            this.ConstructorFunction = rtw.connectivity.SlFIAdaptor.empty;           
            this.SystemResetFunction = rtw.connectivity.SlFIAdaptor.empty;
            this.InitConditionsFunction = rtw.connectivity.SlFIAdaptor.empty;
            this.DerivativeFunction = rtw.connectivity.SlFIAdaptor.empty;
            this.SystemInitializeFunction = rtw.connectivity.SlFIAdaptor.empty;
        end
        
        function prop = getProp(this, propName)
            switch propName
                case {'Inports', 'Outports', 'InternalData', 'TimingProperties', 'Types', ...
                      'NonSampledZeroCrossings', 'ZeroCrossingEvents'}
                    % access the property on the SubsystemInterface
                    prop = this.SubsystemInterface.(propName);
                otherwise
                    % access the property on the ComponentInterface
                    prop = this.CodeDescObj.(propName);
            end
        end
    end
    
end
