CSimReports – Centralized Simulation Reporting
The CSimReports class provides a centralized system for collecting, storing, and reporting simulation messages, warnings, errors, and informational logs.
It supports both persistent in-memory storage and dynamic reporting with optional formatting.
Key Features
-
Report Types: Supports multiple categories via
EReportType:eError,eWarning,eInfo,eTest,eStates,eFatalError. - Persistent Storage: Uses a shared memory object (
shoom::Shm) to store all report data for retrieval or external inspection. - Error Tracking: Maintains an internal list of unique errors with counts and positions in the report text.
- Flexible Reporting: Provides multiple
ReportMsgoverloads and a printf-styleReportmethod for formatted messages. - Access Reports:
GetReportPtrprovides raw access to the report data and size.
Internal Structure
| Member | Description |
|---|---|
| simEngReports | Unique pointer to shared memory for storing all report messages. |
| text | Raw character buffer containing report text. |
| reportsSize | Current size of the report buffer. |
| errorList | Map of unique errors to CError structures that store position, length, and occurrence count. |
CSimReports::CError
Represents an individual error or warning tracked in the report system:
- spos: Position of the message in the report text.
- length: Length of the error message.
- counter: Number of times this error has occurred.
Usage Examples
// Setup the reporting system
CSimReports::SetupReports();
// Simple informational message
CSimReports::ReportMsg(CSimReports::eInfo, "Simulation started");
// Message with additional details
CSimReports::ReportMsg(CSimReports::eWarning, "Potential issue detected", "Extra info", 5);
// Formatted report
CSimReports::Report(CSimReports::eError, "Error code %d at frame %d", errorCode, frameNum);
// Access raw report data
size_t size;
uint8_t* reportData = CSimReports::GetReportPtr(size);
if(reportData) {
// process report buffer
}
Notes
- All reporting methods are static – no instance creation is needed.
- Error messages are deduplicated and counted using
errorList. - Shared memory allows external inspection of the simulation report buffer.