SystemConsoleHandler Class Reference

Class, that handle messages to console and also exit/abort calls. More...

#include <avrerror.h>

Collaboration diagram for SystemConsoleHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SystemConsoleHandler ()
 creates a SystemConsoleHandler instance
 ~SystemConsoleHandler ()
void SetUseExit (bool useExit=true)
 Tells the handler, that exit/abort is to use instead of exceptions.
void SetMessageStream (std::ostream *s)
 Sets the output stream, where messages are sent to.
void SetWarningStream (std::ostream *s)
 Sets the output stream, where warnings and errors are sent to.
void SetTraceFile (const char *name, unsigned int maxlines=0)
 Sets the trace to file stream and enables tracing global.
void SetTraceStream (std::ostream *s)
 Sets the trace to given stream and enables tracing global.
void StopTrace (void)
 Stops tracing global, close file, if set, redirect trace to nullStream.
bool GetTraceState (void)
 Returns true, if tracing is global enabled.
std::ostream & traceOutStream (void)
 Gives Access to trace stream.
void TraceNextLine (void)
 Ends a trace line, performs reopen new filestream, if necessary.
void vfmessage (const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
 Format and send a message to message stream (default stdout).
void void vfwarning (const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
 Format and send a warning message to warning stream (default stderr).
void void void vferror (const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
 Format and send a error message to warning stream (default stderr).
void void void
ATTRIBUTE_NORETURN void 
vffatal (const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
 Format and send a error message to stderr and call exit or raise a exception.
void void void
ATTRIBUTE_NORETURN void
ATTRIBUTE_NORETURN void 
AbortApplication (int code)
 Aborts application: uses abort or exception depending on useExitAndAbort.
ATTRIBUTE_NORETURN void ExitApplication (int code)
 Exits application: uses exit or exception depending on useExitAndAbort.

Protected Member Functions

char * getFormatString (const char *prefix, const char *file, int line, const char *fmtstr)
 Creates the format string for formatting a message.

Protected Attributes

bool useExitAndAbort
 Flag, if exit/abort have to be used instead of exceptions.
char formatStringBuffer [128]
 Buffer for format strings to format a message.
char messageStringBuffer [512]
 Buffer for built message string itself.
std::ostream * msgStream
 Stream, where normal messages are sent to.
std::ostream * wrnStream
 Stream, where warning and error messages are sent to.
std::ostream * traceStream
 Stream for trace output.
std::ostream * nullStream
 /dev/null! ;-)
bool traceEnabled
 flag, true if trace is enabled
bool traceToFile
 flag, true if trace writes to filestream
std::string traceFilename
 file name for trace file (will be appended with file count!)
unsigned int traceLinesOnFile
 how much lines will be written on one trace file
unsigned int traceLines
 how much lines are written on current trace file
int traceFileCount
 Counter for trace files.

Detailed Description

Class, that handle messages to console and also exit/abort calls.

Definition at line 43 of file avrerror.h.


Constructor & Destructor Documentation

SystemConsoleHandler::SystemConsoleHandler (  ) 

creates a SystemConsoleHandler instance

This is needed only once for a application, see global variable sysConHandler, where such instance is created by default.

Definition at line 53 of file avrerror.cpp.

References msgStream, nullStream, traceEnabled, traceStream, useExitAndAbort, and wrnStream.

SystemConsoleHandler::~SystemConsoleHandler (  ) 

Definition at line 62 of file avrerror.cpp.

References nullStream, and StopTrace().

Here is the call graph for this function:


Member Function Documentation

void SystemConsoleHandler::AbortApplication ( int  code  ) 

Aborts application: uses abort or exception depending on useExitAndAbort.

Definition at line 179 of file avrerror.cpp.

References useExitAndAbort.

Referenced by RWAbort::get(), and RWAbort::set().

Here is the caller graph for this function:

void SystemConsoleHandler::ExitApplication ( int  code  ) 

Exits application: uses exit or exception depending on useExitAndAbort.

Definition at line 194 of file avrerror.cpp.

References useExitAndAbort.

Referenced by RWExit::get(), and RWExit::set().

Here is the caller graph for this function:

char * SystemConsoleHandler::getFormatString ( const char *  prefix,
const char *  file,
int  line,
const char *  fmtstr 
) [protected]

Creates the format string for formatting a message.

Definition at line 202 of file avrerror.cpp.

References formatStringBuffer.

Referenced by vferror(), vffatal(), vfmessage(), and vfwarning().

Here is the caller graph for this function:

bool SystemConsoleHandler::GetTraceState ( void   )  [inline]

Returns true, if tracing is global enabled.

Definition at line 66 of file avrerror.h.

References traceEnabled.

Referenced by main().

Here is the caller graph for this function:

void SystemConsoleHandler::SetMessageStream ( std::ostream *  s  ) 

Sets the output stream, where messages are sent to.

Definition at line 71 of file avrerror.cpp.

References msgStream.

void SystemConsoleHandler::SetTraceFile ( const char *  name,
unsigned int  maxlines = 0 
)

Sets the trace to file stream and enables tracing global.

Definition at line 79 of file avrerror.cpp.

References StopTrace(), traceEnabled, traceFileCount, traceFilename, traceLines, traceLinesOnFile, traceStream, and traceToFile.

Referenced by avr_trace_tf(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void SystemConsoleHandler::SetTraceStream ( std::ostream *  s  ) 

Sets the trace to given stream and enables tracing global.

Definition at line 92 of file avrerror.cpp.

References StopTrace(), traceEnabled, traceStream, and traceToFile.

Here is the call graph for this function:

void SystemConsoleHandler::SetUseExit ( bool  useExit = true  ) 

Tells the handler, that exit/abort is to use instead of exceptions.

Definition at line 67 of file avrerror.cpp.

References useExitAndAbort.

void SystemConsoleHandler::SetWarningStream ( std::ostream *  s  ) 

Sets the output stream, where warnings and errors are sent to.

Definition at line 75 of file avrerror.cpp.

References wrnStream.

void SystemConsoleHandler::StopTrace ( void   ) 

Stops tracing global, close file, if set, redirect trace to nullStream.

Definition at line 99 of file avrerror.cpp.

References nullStream, traceEnabled, traceStream, and traceToFile.

Referenced by avr_trace_tf(), SetTraceFile(), SetTraceStream(), and ~SystemConsoleHandler().

Here is the caller graph for this function:

void SystemConsoleHandler::TraceNextLine ( void   ) 

Ends a trace line, performs reopen new filestream, if necessary.

Definition at line 108 of file avrerror.cpp.

References traceEnabled, traceFileCount, traceFilename, traceLines, traceLinesOnFile, traceStream, and traceToFile.

Referenced by AvrDevice::Step().

Here is the caller graph for this function:

std::ostream& SystemConsoleHandler::traceOutStream ( void   )  [inline]

Gives Access to trace stream.

Definition at line 68 of file avrerror.h.

References traceStream.

Referenced by trioaccess().

Here is the caller graph for this function:

void SystemConsoleHandler::vferror ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Format and send a error message to warning stream (default stderr).

Definition at line 153 of file avrerror.cpp.

References getFormatString(), messageStringBuffer, and wrnStream.

Here is the call graph for this function:

void SystemConsoleHandler::vffatal ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Format and send a error message to stderr and call exit or raise a exception.

Definition at line 165 of file avrerror.cpp.

References getFormatString(), messageStringBuffer, useExitAndAbort, and wrnStream.

Here is the call graph for this function:

void SystemConsoleHandler::vfmessage ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Format and send a message to message stream (default stdout).

Definition at line 130 of file avrerror.cpp.

References getFormatString(), messageStringBuffer, msgStream, and wrnStream.

Here is the call graph for this function:

void SystemConsoleHandler::vfwarning ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Format and send a warning message to warning stream (default stderr).

Definition at line 141 of file avrerror.cpp.

References getFormatString(), messageStringBuffer, and wrnStream.

Here is the call graph for this function:


Member Data Documentation

Buffer for format strings to format a message.

Definition at line 95 of file avrerror.h.

Referenced by getFormatString().

Buffer for built message string itself.

Definition at line 96 of file avrerror.h.

Referenced by vferror(), vffatal(), vfmessage(), and vfwarning().

std::ostream* SystemConsoleHandler::msgStream [protected]

Stream, where normal messages are sent to.

Definition at line 97 of file avrerror.h.

Referenced by SetMessageStream(), SystemConsoleHandler(), and vfmessage().

std::ostream* SystemConsoleHandler::nullStream [protected]

/dev/null! ;-)

Definition at line 100 of file avrerror.h.

Referenced by StopTrace(), SystemConsoleHandler(), and ~SystemConsoleHandler().

flag, true if trace is enabled

Definition at line 101 of file avrerror.h.

Referenced by GetTraceState(), SetTraceFile(), SetTraceStream(), StopTrace(), SystemConsoleHandler(), and TraceNextLine().

Counter for trace files.

Definition at line 106 of file avrerror.h.

Referenced by SetTraceFile(), and TraceNextLine().

std::string SystemConsoleHandler::traceFilename [protected]

file name for trace file (will be appended with file count!)

Definition at line 103 of file avrerror.h.

Referenced by SetTraceFile(), and TraceNextLine().

unsigned int SystemConsoleHandler::traceLines [protected]

how much lines are written on current trace file

Definition at line 105 of file avrerror.h.

Referenced by SetTraceFile(), and TraceNextLine().

unsigned int SystemConsoleHandler::traceLinesOnFile [protected]

how much lines will be written on one trace file

Definition at line 104 of file avrerror.h.

Referenced by SetTraceFile(), and TraceNextLine().

std::ostream* SystemConsoleHandler::traceStream [protected]

Stream for trace output.

Definition at line 99 of file avrerror.h.

Referenced by SetTraceFile(), SetTraceStream(), StopTrace(), SystemConsoleHandler(), TraceNextLine(), and traceOutStream().

flag, true if trace writes to filestream

Definition at line 102 of file avrerror.h.

Referenced by SetTraceFile(), SetTraceStream(), StopTrace(), and TraceNextLine().

Flag, if exit/abort have to be used instead of exceptions.

Definition at line 94 of file avrerror.h.

Referenced by AbortApplication(), ExitApplication(), SetUseExit(), SystemConsoleHandler(), and vffatal().

std::ostream* SystemConsoleHandler::wrnStream [protected]

Stream, where warning and error messages are sent to.

Definition at line 98 of file avrerror.h.

Referenced by SetWarningStream(), SystemConsoleHandler(), vferror(), vffatal(), vfmessage(), and vfwarning().


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:53:11 2012 for Simulavr by  doxygen 1.6.3