Overview

The RoseErrorStats class saves summary information about issues that are reported through the RoseErrorReporter. Issues are tracked by the RoseError summary string if present, or by the numeric RoseErrorCode if not. The code and severity are kept as well. Statistics are NOT kept for messages (zero severity), only for things with a non-zero severity.

The RoseErrorReporter keeps a stack of stats objects and the top element of this stack will be used when reporting a message.

RoseErrorCount struct

struct RoseErrorCount {
    const char * 	f_summary;
    RoseErrorCode 	f_errcode;
    RoseStatus	 	f_severity;
    unsigned 	 	f_count;
    unsigned 	 	f_fixed;
};
The RoseErrorCount structure holds occurrence counts and other information for an individual error message. The RoseErrorStats class builds a table of these structures to hold the statistics for all reported errors.

append()

void append (RoseErrorStats * other);
The append() function adds the counts held by the "other" argument to the statistics held by the RoseErrorStats object that it is called on. You can use this to get a snapshot from an operation like reading a file, and then merge those statistics into a larger count after you pop your object off of the stack of stats objects.

Example

RoseErrorStats all_stats;
RoseErrorStats reading_stats;

ROSE.error_reporter()-> push_stats(&all_stats);

// various code that may issue messages


ROSE.error_reporter()-> push_stats(&reading_stats);
RoseDesign * d = ROSE.findDesign ("airplane.stp");
ROSE.error_reporter()-> pop_stats();

if (reading_stats.status() >= ROSE_STATUS_ERROR) {
	printf ("Big troubles reading!\n");
}

all_stats.append (&reading_stats);

// all_stats now contains all messages seen so far, including 
// everything from the file read operation.

counts()

unsigned counts (RoseErrorCode);
unsigned counts (RoseErrorCode ec_min, RoseErrorCode ec_max);
The counts() function examines all the statistics and calculates the total counts for one RoseErrorCode or a range of codes. A single code like ROSE_GENERAL may show up with a different summaries, so it may show up in a several RoseErrorCount entries in the internal table.

Example

This example uses one of the predefined errors issued by the ROSE file reading code.

RoseErrorStats reading_stats;

ROSE.error_reporter()-> push_stats(&reading_stats);
RoseDesign * d = ROSE.findDesign ("airplane.stp");
ROSE.error_reporter()-> pop_stats();

if (reading_stats.counts (ROSE_IO_NO_ANDOR)) {
	printf ("File is missing some complex instance combinations!\n");
}

get_stats_by_index()

RoseErrorCount * get_stats_by_index (unsigned idx);

The get_stats_by_index function returns a RoseErrorCount element from the table within the statistics object. The order of elements within the table is not defined. The size() function returns the size of the table.

Example

void print_stats (RoseErrorStats * es)
{
    unsigned i, sz;

    printf ("--------------------\n");
    printf ("max status is %d\n", es->status());

    for (i=0, sz=es->size(); i<sz; i++)
    {
	RoseErrorCount * ct = es-> get_stats_by_index(i);
	printf ("[%d] CODE %lu, SEV %u, COUNT %u - %s\n", i, 
		ct->f_errcode,
		ct->f_severity,
		ct->f_count, 
		ct->f_summary);
    }
    printf ("--------------------\n\n");
}

reset()

void reset();

The reset() function deletes all statistics kept in the internal table and sets the cumulative status() value to zero (ROSE_OK).

status()

RoseStatus status()

The status() function returns the maximum severity of all issues reported since the last reset()

size()

unsigned size();

The size function returns the number of RoseErrorCount elements in the table of predefined errors held by the object, primarily for examining all elements using get_stats_by_index()