function mode_out = featureOn(feature, mode_in)
%

% Copyright 2019 The MathWorks, Inc.

mlock;
persistent features;

if isempty(features)
    features = struct(...
        'IntelToolchain', false, ...
        'SilPwsReusableLibs', false,...
        'ExplicitLibClosing', true);
end

assert(isfield(features, feature),...
    'Feature ''%s'' is not available!', feature);

% Check for outputs
if nargout == 1
    mode_out = features.(feature);
end

% Check for inputs
if nargin >= 2
    
    % Verify type before continuing    
    % new value must be boolean
    assert(islogical(mode_in),...
        'Feature value for ''%s'' must be a logical!', feature)
    
    % Assign new value to struct field.
    features.(feature) = mode_in;
    
end
