classdef (Hidden = true) StandaloneCodeInterfaceFactory < rtw.pil.CodeInterfaceFactory
    %STANDALONECODEINTERFACEFACTORY Factory for SIL/PIL standalone code interface objects
    %
    %   This is an undocumented class. Its methods and properties are likely to
    %   change without warning from one release to the next.
    
    %   Copyright 2010-2021 The MathWorks, Inc.
    
 
    methods
        
        function this = StandaloneCodeInterfaceFactory(isAutosar)
            this.IsAutosar = isAutosar;
        end
        
        function codeInfoUtils = createCodeInfoUtils(this, ...
                codeInfoPath, clientInterface, configInterface, componentName, runValidation)
            
            if this.IsAutosar
                strategy = coder.internal.connectivity.AutosarCodeDescriptorStrategy();
            else
                strategy = coder.internal.connectivity.CodeDescriptorStrategy();
            end
            codeInfoUtils = coder.connectivity.StandaloneCodeInfoUtils( ...
                codeInfoPath, clientInterface, configInterface, componentName, runValidation, ...
                'CodeDescriptorStrategy', strategy);
        end
        
        function silPILWrapperUtils = createSILPILWrapperUtils(~, ...
                                                        silPILInterface, ...
                                                        infoStruct, ...
                                                        clientInterface,...
                                                        topModelOriginalParams, ...
                                                        lXilCompInfo)
            if silPILInterface.isModelBlockXIL
                silPILWrapperUtils = rtw.pil.ModelRefSILPILWrapperUtils(...
                    silPILInterface, ...
                    infoStruct, ...
                    clientInterface, ...
                    topModelOriginalParams, ...
                    lXilCompInfo);
            else
                silPILWrapperUtils = rtw.pil.StandaloneSILPILWrapperUtils(...
                    silPILInterface, ...
                    infoStruct, ...
                    clientInterface, ...
                    topModelOriginalParams, ...
                    lXilCompInfo);
            end
        end
        
        function hostSfun = createHostSfunction(this, ...
                                                silPILWrapperUtils, ...
                                                sfunSourcePath, ...
                                                sfunBinDir)
            if silPILWrapperUtils.getSILPILInterface.isModelBlockXIL
                hostSfun = rtw.pil.ModelBlockSfunction(silPILWrapperUtils, ....
                    sfunSourcePath, ...
                    sfunBinDir);
            else
                if this.IsAutosar
                    hostSfun = rtw.pil.AutosarSfunction(silPILWrapperUtils, ....
                        sfunSourcePath, ...
                        sfunBinDir);
                else
                    hostSfun = rtw.pil.PILBlockSfunction(silPILWrapperUtils, ....
                        sfunSourcePath, ...
                        sfunBinDir);
                end
            end
        end
        
        function targetInterface = createTargetInterface(this, ...
                                                         silPILWrapperUtils, ...
                                                         pilInterfaceTarget) 
            if this.IsAutosar
                strategy = coder.internal.connectivity.AutosarInterfaceStrategy(silPILWrapperUtils);
            else
                strategy = coder.internal.connectivity.TargetInterfaceStrategy(silPILWrapperUtils);
            end
            targetInterface = rtw.pil.StandaloneTargetInterface(silPILWrapperUtils, ...
                pilInterfaceTarget, 'InterfaceStrategy', strategy);
        end
    end
end
