ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Inner Classes | Public Static Methods | Public Methods | Protected Static Fields | Protected Fields | List of all members
Report Class Reference
Collaboration diagram for Report:
[legend]

Class Description


This class provides a simple facility to collect what is called a 'report'. Reports are maintenance messages, mostly error and warning messages, but is not aiming to replace any sort of error handling. (In ALib itself, sending a 'report' usually precedes raising an error.) Also, reports are not replacing any debug or release logging facility, which is not part of ALib. Much more, logging libraries might provide a derived object of type ReportWriter to plug into ALib report facility. This way, the concepts of logging and reports get unified. (As a sample, ALox Logging Library which builds on ALib does so.)

While a process can create different objects of this class, usually, the default instance, received by GetDefault. is sufficient and all warnings and errors will be directed to this one. ALib itself directs all internal reports to the default instance.

This class uses a singleton of type ReportWriter to actually write the reports. By default, an object of type ReportWriterStdIO is attached.

The reporting method, DoReport will check the flags provided with PushHaltFlags for message types 0 (errors) and 1 (warnings), and may invoke assert(). Such assertions are effective only in the debug compilation of the library/executable. Custom 'ReportWriters' might take action (e.g. for security reasons) and e.g. terminate the application also in release compilations.

To simplify things, a set of static methods are defined in class ALIB which are deemed to be pruned in release versions of the compilation unit. These are:

The use of these methods is recommended and preferred over the direct use of class Report whenever pure debug reports are intended.

Inner Classes

class  Message
 

Public Static Methods

static Report GetDefault ()
 

Public Methods

 Report ()
 
void DoReport (int type, Object msg, Object optMsg2=null, Object optMsg3=null, Object optMsg4=null, [CallerFilePath] String csf="", [CallerLineNumber] int cln=0, [CallerMemberName] String cmn="")
 
ReportWriter PeekWriter ()
 
void PopHaltFlags ()
 
void PopWriter (ReportWriter checkWriter)
 
void PushHaltFlags (bool haltOnErrors, bool haltOnWarnings)
 
void PushWriter (ReportWriter newWriter)
 

Protected Static Fields

static Report defaultReport =new Report()
 

Protected Fields

Stack< int > haltAfterReport = new Stack<int>()
 
ThreadLock Lock =new ThreadLock()
 
bool recursionBlocker = false
 
Stack< ReportWriterwriters =new Stack<ReportWriter>()
 

Constructor & Destructor Documentation

◆ Report()

Report ( )
inline

Constructor

Member Function Documentation

◆ DoReport()

void DoReport ( int  type,
Object  msg,
Object  optMsg2 = null,
Object  optMsg3 = null,
Object  optMsg4 = null,
[CallerFilePath] String  csf = "",
[CallerLineNumber] int  cln = 0,
[CallerMemberName] String  cmn = "" 
)
inline

Reports the given message to the current ReportWriter in place. The default ReportWriter will print the message on the process console. Furthermore, in debug execution the flags provided with PushHaltFlags is checked. If this is set for the type of message, the program halts or suspends into the debugger (platform and language specific).

If parameter is '0', the report is considered a severe error, otherwise a warning. User defined implementations of class ReportWriter may interpret this field arbitrarily.

Parameters
typeThe report type.
msgThe report object.
optMsg2An optional additional report object.
optMsg3An optional additional report object.
optMsg4An optional additional report object.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ GetDefault()

static Report GetDefault ( )
inlinestatic

Receives the default report object used by ALib and processes that rely on ALib.

Returns
The default Report.

◆ PeekWriter()

ReportWriter PeekWriter ( )
inline

Retrieves the actual report writer.

Note
This method should not be used to retrieve the writer and use it. It should be used only to test the installation.
Returns
The actual report writer in place.

◆ PopHaltFlags()

void PopHaltFlags ( )
inline

Restores the previous values after an invocation to PushHaltFlags.

◆ PopWriter()

void PopWriter ( ReportWriter  checkWriter)
inline

Restores the previous writer after setting a new one using PushWriter. It is important to keep the right order when pushing and popping writers, as there lifetime is externally managed. (In standard use-cases, only one, app-specific writer should be pushed anyhow). To give a little assurance, this method PopWriter takes the same parameter as PushWriter does, to verify if the one to be removed is really the topmost.

Parameters
checkWriterThe previously pushed writer (for checking of call order).

◆ PushHaltFlags()

void PushHaltFlags ( bool  haltOnErrors,
bool  haltOnWarnings 
)
inline

Writes new values to the internal flags that decide if calls to DoReport with report type '0' (errors), respectively report type '>0' (warnings) cause to halt program execution by calling assert(false). The previous values can be restored using PopHaltFlags.

Parameters
haltOnErrorsSpecifies if halting on errors is wanted.
haltOnWarningsSpecifies if halting on warnings is wanted.

◆ PushWriter()

void PushWriter ( ReportWriter  newWriter)
inline

Sets a new writer. The actual writer is implemented as a stack. It is important to keep the right order when pushing and popping writers, as there lifetime is externally managed. (In standard use-cases, only one, app-specific writer should be pushed anyhow). To give a little assurance, method PopWriter takes the same parameter as this method does, to verify if if the one to be removed is really the topmost.

Parameters
newWriterThe writer to use.

Member Data Documentation

◆ defaultReport

Report defaultReport =new Report()
staticprotected

The default Report used internally by ALib and usually by processes that rely on ALib.

◆ haltAfterReport

Stack<int> haltAfterReport = new Stack<int>()
protected

A stack of integers. The topmost value is used to decide, whether program execution is halted on message of type 'error' (type 0, bit 0) or of type 'warning' (type 1, bit 1). Can be set at runtime using methods PushHaltFlags and PopHaltFlags.

◆ Lock

ThreadLock Lock =new ThreadLock()
protected

A Lock to protect against multihreaded calls.

◆ recursionBlocker

bool recursionBlocker = false
protected

This is a flag that avoids recursion. Recursion might occur when a more sophisticated report writer sends a report (e.g. an ALIB Error or Warning). Recursive calls are rejected without further notice.

◆ writers

Stack<ReportWriter> writers =new Stack<ReportWriter>()
protected

A stack of writers. The topmost one is the actual. Can be set at runtime using methods PushWriter and PopWriter.


The documentation for this class was generated from the following file: