Class ThreadSafeErrorCollector¶
Defined in File gaussian_extractor.h
Class Documentation¶
-
class ThreadSafeErrorCollector¶
Thread-safe collection and management of error and warning messages.
The ThreadSafeErrorCollector provides a centralized, thread-safe mechanism for collecting error and warning messages from multiple processing threads. It ensures that messages are properly synchronized and can be safely retrieved for display or logging.
Safety¶
All methods use internal synchronization to ensure thread safety:
Multiple threads can add messages simultaneously
Message retrieval is atomic and returns consistent snapshots
No external synchronization is required by users
Categories¶
Errors: Critical issues that prevent successful processing
Warnings: Non-critical issues that users should be aware of
Note
Error and warning collections are maintained separately to allow different handling and display strategies for each category
Public Functions
-
void add_error(const std::string &error)¶
Add an error message to the collection.
Thread-safe addition of error messages. Multiple threads can call this method simultaneously without external synchronization.
Note
Error messages indicate critical issues that prevent successful completion of operations
- Parameters:
error – Error message to add
-
void add_warning(const std::string &warning)¶
Add a warning message to the collection.
Thread-safe addition of warning messages. Multiple threads can call this method simultaneously without external synchronization.
Note
Warning messages indicate non-critical issues that users should be aware of but don’t prevent operation completion
- Parameters:
warning – Warning message to add
-
std::vector<std::string> get_errors() const¶
Retrieve all collected error messages.
Returns a snapshot of all error messages collected so far. The returned vector is a copy and can be safely used without additional synchronization.
- Returns:
Vector containing all error messages
-
std::vector<std::string> get_warnings() const¶
Retrieve all collected warning messages.
Returns a snapshot of all warning messages collected so far. The returned vector is a copy and can be safely used without additional synchronization.
- Returns:
Vector containing all warning messages
-
bool has_errors() const¶
Check if any error messages have been collected.
Thread-safe check for the presence of error messages. Useful for determining if operations completed successfully.
- Returns:
true if errors exist, false otherwise
-
void clear()¶
Clear all collected messages.
Removes all error and warning messages from the collections. Thread-safe operation that can be called to reset the collector for reuse in subsequent operations.