classdef (Hidden = true) WrapperUtils < matlab.mixin.Copyable
%WRAPPERUTILS code interface utilities
%
%   This is an undocumented class. Its methods and properties are likely to
%   change without warning from one release to the next.

%   Copyright 2011-2019 The MathWorks, Inc.

    % properties
    properties (SetAccess = 'protected', GetAccess = 'protected', NonCopyable = true)
        % do not copy this property on copy operations
        CodeInfoUtils;                        
    end
    
    properties (SetAccess = 'private', GetAccess = 'private')
        InfoStruct;
        ConfigInterface;
    end
    
    methods
        function this = WrapperUtils(infoStruct, configInterface)
            narginchk(2, 2);
            % validate args
            rtw.connectivity.Utils.validateArg(configInterface, ...
                'coder.connectivity.ConfigInterface');                        
    
            % store codeInfo
            this.InfoStruct = infoStruct;              
            this.ConfigInterface = configInterface;
        end                
        
        function set.CodeInfoUtils(this, aCodeInfoUtils)
            % validate and set CodeInfoUtils
            rtw.connectivity.Utils.validateArg(aCodeInfoUtils, ...
                'rtw.connectivity.CodeInfoUtils');
            this.CodeInfoUtils = aCodeInfoUtils;
        end
        
        % accessor for CodeInfoUtils
        function codeInfoUtils = getCodeInfoUtils(this)
            codeInfoUtils = this.CodeInfoUtils;
        end
        
        % accessor for CodeInfo
        function codeInfo = getCodeInfo(this)
           codeInfo = this.CodeInfoUtils.getCodeInfo; 
        end
        
        % accessor for InfoStruct
        function infoStruct = getInfoStruct(this)
           infoStruct = this.InfoStruct; 
        end
        
        % accessor for ConfigInterface
        function cs = getConfigInterface(this)
          cs = this.ConfigInterface;
        end

        function ret = isValidParam(this, param)
            ret = this.ConfigInterface.isValidParam(param);
        end
        
        % accessor for ConfigInterface params
        function value = getParam(this, param)
           value = this.ConfigInterface.getParam(param);                        
        end     
    end
    
    methods(Access = protected)
        function cpObj = copyElement(this)
            % create a copy of this object
            cpObj = copyElement@matlab.mixin.Copyable(this);
            % call copy on CodeInfoUtils, this creates a copied object
            % whose non-copyable properties are empty and effectively 
            % disconnects CodeDescriptor
            cpObj.CodeInfoUtils = this.CodeInfoUtils.copy;
        end
    end
end
