function [headings, definitionList] = profReportColumnHeadings(columns, unitsArg, unitsSIArg, definitionList)
%PROFREPORTCOLUMNHEADINGS returns column headings for profiling report

%   Copyright 2010-2017 The MathWorks, Inc.

if isempty(unitsSIArg)
    unitsSIStr = unitsArg;
else
    unitsSIStr = unitsSIArg;
end

if isempty(definitionList)
    definitionList = containers.Map('KeyType', 'char' ,'ValueType', 'any');
end

numCols = length(columns);
headings = cell(1, numCols);

for i=1:numCols
    switch columns(i)
      case coder.profile.ResultColumns.Model
        headings{i} = DAStudio.message('CoderProfile:ExecutionTime:ColumnHeadingSection');
      case coder.profile.ResultColumns.MaxTurnaround
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:MaxTurnaroundTimeTooltip', unitsArg), ...
             DAStudio.message('CoderProfile:ExecutionTime:MaxTurnaroundTime', unitsSIStr));
        keyDefinition = DAStudio.message('CoderProfile:ExecutionTime:TurnaroundTimeLabel');
        valueDefinition = DAStudio.message('CoderProfile:ExecutionTime:TurnaroundTimeDefinition');
        definitionList(keyDefinition) = valueDefinition;
      case coder.profile.ResultColumns.AverageTurnaround
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:AvTurnaroundTimeTooltip', unitsArg),...  
             DAStudio.message('CoderProfile:ExecutionTime:AvTurnaroundTime', unitsSIStr));
      case coder.profile.ResultColumns.MaxRealTimeExecution
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:MaxRealTimeExecutionTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:MaxExecutionTime', unitsSIStr));
        keyDefinition = DAStudio.message('CoderProfile:ExecutionTime:ExecutionTimeLabel');
        valueDefinition = DAStudio.message('CoderProfile:ExecutionTime:RealTimeExecutionTimeDefinition');
        definitionList(keyDefinition) = valueDefinition;
      case coder.profile.ResultColumns.MaxNonRealTimeExecution
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:MaxNonRealTimeExecutionTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:MaxExecutionTime', unitsSIStr));
        keyDefinition = DAStudio.message('CoderProfile:ExecutionTime:ExecutionTimeLabel');
        valueDefinition = DAStudio.message('CoderProfile:ExecutionTime:NonRealTimeExecutionTimeDefinition');
        definitionList(keyDefinition) = valueDefinition;
      case coder.profile.ResultColumns.AverageRealTimeExecution
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:AvRealTimeExecutionTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:AvExecutionTime', unitsSIStr));
      case coder.profile.ResultColumns.AverageNonRealTimeExecution
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:AvNonRealTimeExecutionTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:AvExecutionTime', unitsSIStr));
      case coder.profile.ResultColumns.MaxSelf
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:MaxSelfTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:MaxSelfTime', unitsSIStr));
        keyDefinition = DAStudio.message('CoderProfile:ExecutionTime:SelfTimeLabel');
        valueDefinition = DAStudio.message('CoderProfile:ExecutionTime:SelfTimeDefinition');
        definitionList(keyDefinition) = valueDefinition;
      case coder.profile.ResultColumns.AverageSelf
        headings{i} = sprintf...
            ('<a title="%s">%s</a>', ...
             DAStudio.message('CoderProfile:ExecutionTime:AvSelfTimeTooltip', unitsArg),...
             DAStudio.message('CoderProfile:ExecutionTime:AvSelfTime', unitsSIStr));
      case coder.profile.ResultColumns.Calls
        headings{i} = DAStudio.message('CoderProfile:ExecutionTime:ColumnHeadingCalls');
      case coder.profile.ResultColumns.Links
        headings{i} = '';
      otherwise
        assert(false, 'Invalid column specification');
    end
end
