function cvstruct = getTableExecInfo(this, cvstruct,tables, options)
%

% Copyright 2003-2019 The MathWorks, Inc.

    tableExecData = this.metricData.tableExec;
    
    tableCnt = length(tables);
    testCnt = length(cvstruct.tests);
    if testCnt==1
        coumnCnt = 1;
    else
        coumnCnt = testCnt+1;
    end
    
	%Total col is last col
	if options.cumulativeReport
		coumnCnt = testCnt;
    end

    % Preallocate the structure fields
    cvstruct.tables = struct(   'cvId',             num2cell(tables), ...
                                'dimSizes',         cell(1,tableCnt), ... 
                                'breakPtValues',    cell(1,tableCnt), ...
                                'covered',          cell(1,tableCnt), ... 
                                'testData',         cell(1,tableCnt));
    
    for i=1:tableCnt
        tableId = tables(i);
        isJustified = cv('get', cv('get', tableId, '.slsfobj'), '.isJustified');
        [cvstruct.tables(i).breakPtValues,cvstruct.tables(i).dimSizes] = ...
                            cv('get',tableId,'.breakPtValues','.dimBrkSizes');

        % WISH we need to modify this to support multiple tables
        for testIdx = 1:coumnCnt
            [~, execCnt, brkEq, executedIn] = tableinfo(tableExecData.dataObjs{testIdx}, cv('get', cv('get',tableId,'.slsfobj'), '.handle'));
            cvstruct.tables(i).testData(testIdx).execCnt = execCnt;
            cvstruct.tables(i).testData(testIdx).breakPtEquality = cat(1,brkEq{:});
            cvstruct.tables(i).testData(testIdx).executedIn = convertTrace(executedIn);
            %shoudl get ther trace from tableinfo
            
        end
            
        % A table is "Covered" if all interpolation intervals are hit.
        cvstruct.tables(i).covered = all(cvstruct.tables(i).testData(end).execCnt);
        cvstruct.tables(i).isJustified = false;
        if  isJustified 
            cvstruct.tables(i).isJustified = ~cvstruct.tables(i).covered;
        end
        

        
    end
end
%=========
 function executedIn = convertTrace(executedIn)
    for idx = 1 : numel(executedIn)
        if isempty(executedIn{idx})
            executedIn(idx) = {''};
        else
            executedIn(idx) = join({executedIn{idx}.traceLabel}, ',');
        end
    end
 end

