classdef (Hidden = true) ClientInterface < handle
%CLIENTINTERFACE Abstract interface to clients such as MATLAB Coder and
%Simulink Coder.
%
%   This is an undocumented class. Its methods and properties are likely to
%   change without warning from one release to the next.
    
%   Copyright 2013-2020 The MathWorks, Inc.
    
    methods (Static)        
        % static accessor for SILPILInterface
        function silPILInterface = getSILPILInterface(getSILPILInterfaceFcnStr, ...
                                                      inTheLoopType,...
                                                      blockPath)                                            
            fcnHandle = eval(getSILPILInterfaceFcnStr);
            silPILInterface = feval(fcnHandle, inTheLoopType, blockPath);                        
        end
        
        function updateCachedSILPILInterface(inTheLoopType, blockPath, data)
            setterFcnHandle = str2func([ ...
                coder.connectivity.PILDataHandler.getPILDataAccessor(inTheLoopType), '.setPILData']);
            setterFcnHandle(blockPath, data);
        end
        
    end

    methods (Abstract)
        
        % Code instrumentation info
        lCodeInstrInfo = getCodeInstrInfo(silPILInterface, lTopModel);
        % factory method to create a ComponentArgs
        componentArgs = createComponentArgs(this, ...
                                            componentPath, ...
                                            componentCodePath, ...
                                            componentCodeName, ...
                                            applicationCodePath, ...
                                            silPILInterface, ...
                                            lTopModel,...
                                            lBuildHooks, ...
                                            lCodeExecutionProfilingEnabled);
                                                        
        % factory method to create a ConfigInterface
        config = createConfigInterface(~, config, codeGenComponent);

        % factory method to create a CoreClientInterface
        clientInterface = createCoreClientInterface(this);
        
        % factory method to create a CodeInterfaceFactory
        codeInterfaceFactory = createCodeInterfaceFactory(this, silPILInterface, config);        
        
        % load infoStruct based on codeDir
        [slprjInternalPath, codeName, infoStruct] = initializeInfoStruct(this, codeDir, inTheLoopType);
                
        % deliver a notification to a specific context
        deliverNotification(this, context, notificationID, notificationMsg);
        
        % close notification given context
        closeNotification(this, context, notificationID);
                       
        % returns, as a string, a function to retrieve the SILPILInterface
        fcnStr = getSILPILInterfaceFcnStr(this);
        
        % callback for Code Coverage
        executionCodeCoverageCallback(this, silPILInterface, blockPath, profData, rootModel, inTheLoopType);
        
        % callback for execution profiling
        executionProfileCallback(this, silPILInterface, blockPath, profData, rootModel, inTheLoopType);
        
        % callback for execution profiling
        executionProfileStartCallback(this, silPILInterface, blockPath, rootModel, inTheLoopType);
        
        % XIL s-function initialize hook
        rootLoggingPath = initializeHookBody(this, topModel, blockPath, inTheLoopType);      
        
        % accessor for block handle
        blockHandle = getBlockHandle(this, blockPath);        
        
        % returns the top-level context of the component under test
        topContext = getTopContext(this, blockPath, silPILInterface);
        
        % dispatch a given BuildHook
        varargout = dispatchBuildHook(this, componentArgs, hookName, hookObj);        
        
        % abstraction for BuildHook getLaunchEnvironmentVars
        envCmds = getLaunchEnvironmentVars(~, componentArgs);        
        
        % Code instrumentation global registry
        lGlobalRegistry = createExecTimeGlobalReg(this, silPILInterface);
        
        % Return component name and reference (e.g. SID)
        [lComponentName, lComponentRef] = getComponentName(this, lComponentPath) 
        
        % update the code generation report
        updateReport(this, silPILInterface, buildInfo, wrapperInfoReportOutOfDate, ...
            lDefaultMexCompilerKey);
        
        % return whether State Logging is enabled
        isStateLoggingEnabled = isStateLoggingEnabled(this, silPILWrapperUtils, inTheLoopType);

        % State logging initialization
        [loggingData, supportedDataInterfaces] = ...
                initializeStateLoggingData(this, silPILWrapperUtils, stateBlocks, ...
                        isPostUpload, offset, inTheLoopType);

        % returns whether Signal Logging is enabled
        isLoggingEnabled = isSignalLoggingEnabled(this, silPILWrapperUtils, inTheLoopType);
        
        % Signal logging initialization
        [loggingData, ...
         modelLoggingInfoStruct, ...
         supportedDataInterfaces, ...
         loggingIODataTypes] = ...
            initializeSignalLoggingData(this, ...
                                        silPILWrapperUtils, ...
                                        capiData, ...
                                        cachedXILBlockModelLoggingInfo, ...
                                        inTheLoopType, ...
                                        sigLogInfo);
                             
        % return the model_private.h header to include if required
        privateHeader = getPrivateHeader(this, silPilWrapperUtils);
                      
        % initialization for internal performance profiling
        [isProfilingEnabled, ...
            profilingMdlRefTgtType] = initializePerfProfiling(this, rootModel, inTheLoopType);
        
        % record an internal performance profiling point
        perfProfile(this, desc, startOrEnd, isProfilingEnabled, profilingMdlRefTgtType, rootModel);                         
        
        % get message displayed at the start of SIL simulation
        startMessage = getSILStartMessage(this, componentPath);
        
        % get message displayed at the end of SIL simulation
        stopMessage = getSILStopMessage(this, componentPath);
        
        % return whether EnablePauseTimes is enabled
        isEnabled = isPauseTimesEnabled(this, topContext);
        
        % return whether this is the MATLAB Coder DLL target
        isDLL = isDLLTarget(this, configInterface);
        
        % returns struct containing info relating to long long support
        longLongInfo = getLongLongInfo(this);
        
        % Is it a MATLAB Coder build
        val = ciIsMATLABCodeGen(this);
        
        % updates the file extension of main component library
        modelLib = updateModelLibExt(this, modelLib);

        % returns any additional directories that should be added to the
        % system path before launching the application.
        extraPaths = additionalSystemPaths(this, componentArgs);
        % Determine if a DataElement with Matrix Type in CodeInfo is
        % implemented as an array in generated code
        isMatrix = isArray(this, dimensions);
        
        % Determine whether target should synchronize I/O during one shot calls
        syncIODuringOneShot = syncIODuringOneShot(this);
        
        % Determine whether internal code coverage support is enabled
        isEnabled = isMWCodeCoverageEnabled(this);
        
        % Validate Use of Global Data Stores
        validateGlobalDataStores(this, wrapperUtils, inTheLoopType, silPILInterface, dataStoreList);
        
        % Open callback for the rtiostream
        rtIOStreamPreOpen(this, rtIOStream, isSIL);
        
        % Enable feature control withing Sfunction.m without calling
        % slfeature.
        xilNoWrapper = XilNoWrapper(this);
        
        % Returns whether CodeInfo Implementation.CodeType should be used
        useCodeType = useCodeType(this);
    end    
end
