LightsprintSDK 2021.08.08
|
#include <RRDebug.h>
Public Member Functions | |
virtual void | customReport (RRReportType type, int indentation, const char *message)=0 |
RRReporter () | |
virtual | ~RRReporter () |
Public Member Functions inherited from rr::RRUniformlyAllocated | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Static Public Member Functions | |
static void | report (RRReportType type, const char *format,...) |
static void | reportV (RRReportType type, const char *format, va_list &vars) |
static void | indent (int delta) |
static void | assertionFailed (const char *expression, const char *func, const char *file, unsigned line) |
static void | setFilter (bool warnings=true, unsigned infLevel=2, bool timing=true) |
static void | getFilter (bool &warnings, unsigned &infLevel, bool &timing) |
static RRReporter * | createFileReporter (const char *filename, bool caching) |
static RRReporter * | createPrintfReporter () |
static RRReporter * | createOutputDebugStringReporter () |
static RRReporter * | createWindowedReporter (class RRSolver *&solver, const char *caption=nullptr, bool closeWhenDone=false) |
static const char * | bytesToString (size_t bytes) |
Additional Inherited Members | |
Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable | |
RRUniformlyAllocatedNonCopyable () | |
~RRUniformlyAllocatedNonCopyable () | |
Reporting messages.
When you or Lightsprint internals call static RRReporter::report(), message is passed to all existing reporters. At the beginning, there are no reporters, messages are lost. If you encounter problems, it could help to create reporter and check messages.
Thread safe: yes with exception, multiple threads may report at once, multiple threads may create/delete reporters at once, but you must not create/delete reporters and report at the same time (very unlikely case). All new implementations must be at least this thread safe too.
rr::RRReporter::RRReporter | ( | ) |
|
virtual |
|
pure virtual |
Generic report of message. The only function you implement in custom reporter.
It is usually called by Lightsprint internals with message for you.
type | Type of message. |
indentation | Indentation for structured messages. Submessages (e.g. messages from subtask) receive parent indentation + 1. Default indentation is 0. Current indentation is modified by indent(). |
message | Message converted to plain text. |
Thread safe: yes, correct implementation must be thread safe.
|
static |
Shortcut for customReport() with printf syntax: ls for wide strings, hs for singlebyte etc. Usually called by Lightsprint internals with message for you.
|
static |
Shortcut for customReport() with vprintf syntax.
|
static |
Modifies indentation of future reports. +1 extends whitespace size, -1 reduces whitespace.
|
static |
Shortcut for special type of message: assertion failure. Usually called by Lightsprint debug version internals. Assertion failures are not reported in release version.
|
static |
Sets filter for reported messages.
warnings | Enables processing of warning messages (WARN). |
infLevel | Enables processing of INFx messages for x<=infLevel. E.g. 1 enables only the most important INF1 messages, 2 enables also less important INF2 messages. It's good to set at least level 1, preferrably 2, because some error messages could make better sense in context of surrounding info messages. |
timing | Enables processing of timing messages (TIMI). |
|
static |
Returns parameters passed to setFilter().
|
static |
Creates reporter that logs all messages to plain text file. Optional caching makes writes faster but last messages may be lost when program crashes.
|
static |
Creates reporter that calls printf() on each message, with priority highlighting.
|
static |
Creates reporter that calls OutputDebugString() on each message.
|
static |
Creates reporter with its own window to display messages.
Supported only in Windows. If user tries to close the window manually, solver->aborting is set; it's cleared later in reporter destructor. Window is closed when both user attempts to close the window and you delete returned reporter. This means that window may exist even when you delete reporter.
Usage example:
solver | Pointer to solver. It may be nullptr or non-nullptr, you are free to change it at any moment, but restrictions exist:
|
caption | Optional custom window caption, nullptr for default one. |
closeWhenDone | Closes window immediately after reporting ends, rather than asking user what to do. |
|
static |
Helper, converts number of bytes to human readable string, e.g. 12345678 to "12 MB".