
%

%   Copyright 2016 The MathWorks, Inc.

classdef (Hidden) MexWrapper < handle
    
    properties (Hidden, Access = 'private')
        % used as testing hook to add extra MEX options at test time
        MexOptionsFromTestHook; 
    end
    

    methods (Access = 'public')
        
        function this = MexWrapper()
            % constructor, adds no extra options
            
        end
        
        function mex(this, sfunOutDir, mexOptions, sfunSourcePath, mexLibs)
            % add extra MEX options and call mex
            mexOptions = [mexOptions this.getMexOptionsFromTestHook];
            
            mex('-compatibleArrayDims',...
                '-outdir', sfunOutDir, ...
                mexOptions{:}, ...               
                sfunSourcePath, ...
                mexLibs{:});
        end
        
        function setMexOptionsFromTestHook(this, options)
            % public method to add extra options at test time
            this.MexOptionsFromTestHook = options;
        end
        
        function options = getMexOptionsFromTestHook(this)
            % public method to get MexOptionsFromTestHook
            options = this.MexOptionsFromTestHook;
        end
    end
end
