function hOut = getEnumerationInterface(enumName, enumVals, option)
    %GETENUMERATIONINTERFACE returns the interface for handling opCodes
    %   HOUT = getEnumerationInterface(ENUMNAME, ENUMVALS, OPTION) creates 
    %   an implementation of an enumeration ENUMNAME with values ENUMVALS,
    %   and returns an interface to the implementation based on the value of
    %   OPTION. 
    %
    %   If OPTION equals 'enum', a Simulink Enumeration is created
    %   with name ENUMNAME and values ENUMVALS. The enumeration is stored
    %   using the smallest possible integer datatype that can fit the values
    %   in ENUMVALS using one hot encoding (one bit per enum).
    %
    %   If OPTION equals 'struct', a structure encoding ENUMVALS in the
    %   smallest possible built-in unsigned integer type is returned.
    
    % Copyright 2018 The MathWorks, Inc.
    
    
    nOps = length(enumVals);
    switch option
        case 'enum'
            valsOut = fixed.emblib.createOpCodeClass(enumName, enumVals); %#ok<NASGU> 
            % Now, create an interface to the class using a struct
            for ii = 1:nOps
               hOut.(enumVals{ii}) = eval([enumName '.' enumVals{ii}]); 
            end
        case 'struct'
            typeStr = fixed.emblib.GetTypeLabelFromNumOps(nOps, false, 'onehot',true);
            vals = fixed.emblib.GetValuesForEnumeration(nOps, 'onehot', typeStr);
            for ii = 1:nOps
               hOut.(enumVals{ii}) = cast(vals(ii),typeStr); 
            end
        otherwise
            error('Invalid option: use ''enum'' or ''struct'' for parameter ''option''');
    end
    
end
