Cantera  2.0
Public Member Functions | Protected Attributes | List of all members
Application::Messages Class Reference

Class to carry out messages. More...

#include <application.h>

Collaboration diagram for Application::Messages:
[legend]

Public Member Functions

 Messages ()
 Constructor for the Messages class.
 
 Messages (const Messages &r)
 Copy Constructor for the Messages class.
 
Messagesoperator= (const Messages &r)
 Assignment operator.
 
 ~Messages ()
 Destructor for the Messages class.
 
void addError (std::string r, std::string msg)
 Set an error condition in the application class without throwing an exception.
 
int getErrorCount ()
 Return the number of errors that have been encountered so far.
 
void popError ()
 Discard the last error message.
 
std::string lastErrorMessage ()
 Retrieve the last error message in a string.
 
void getErrors (std::ostream &f)
 Prints all of the error messages to an ostream.
 
void logErrors ()
 Prints all of the error messages using writelog.
 
void writelog (const std::string &msg)
 Write a message to the screen.
 
void writelogendl ()
 Write an end of line and flush output.
 
void writelog (const char *pszmsg)
 Write a message to the screen.
 
void logerror (const std::string &msg)
 Write an error message and quit.
 
int getUserEnv ()
 Returns an integer specifying the application environment.
 
void setLogger (Logger *logwriter)
 Install a logger.
 
void beginLogGroup (std::string title, int loglevel)
 Create a new group for log messages.
 
void addLogEntry (std::string tag, std::string value)
 Add an entry to an HTML log file.
 
void addLogEntry (std::string tag, doublereal value)
 Add an entry to an HTML log file.
 
void addLogEntry (std::string tag, int value)
 Add an entry to an HTML log file.
 
void addLogEntry (std::string msg)
 Add an entry to an HTML log file.
 
void endLogGroup (std::string title)
 Close the current group of log messages.
 
void write_logfile (std::string file)
 Write the HTML log file.
 

Protected Attributes

std::vector< std::string > errorMessage
 Current list of error messages.
 
std::vector< std::string > errorRoutine
 Current error Routine.
 
Loggerlogwriter
 Current pointer to the logwriter.
 
XML_Nodexmllog
 Current pointer to the top of the XML_Node tree for the current HTML log.
 
XML_Nodecurrent
 Pointer to the last current position in the XML_Node tree for the current HTML log.
 
int loglevel
 Current value of the loglevel.
 
std::vector< int > loglevels
 Vector of loglevels for loggroups that are open.
 
std::vector< std::string > loggroups
 Current vector of loggroups that are open.
 

Detailed Description

Class to carry out messages.

Definition at line 48 of file application.h.

Constructor & Destructor Documentation

Messages ( )

Constructor for the Messages class.

Constructor for the Messages class which is a subclass of the Application class.

Definition at line 51 of file application.cpp.

References Application::Messages::logwriter.

Messages ( const Messages r)

Copy Constructor for the Messages class.

Constructor for the Messages class which is a subclass of the Application class.

Parameters
rMessage to be copied

Definition at line 68 of file application.cpp.

References Application::Messages::logwriter.

~Messages ( )

Destructor for the Messages class.

Definition at line 102 of file application.cpp.

References Application::write_logfile().

Member Function Documentation

Application::Messages & operator= ( const Messages r)
void writelogendl ( )

Write an end of line and flush output.

Definition at line 161 of file application.cpp.

Referenced by Application::writelogendl().

void logerror ( const std::string &  msg)

Write an error message and quit.

The default behavior is to write to the standard error stream, and then call exit(). Note that no end-of-line character is appended to the message, and so if one is desired it must be included in the string. Note that this default behavior will terminate the application Cantera is invoked from (MATLAB, Excel, etc.) If this is not desired, then derive a class and reimplement this method.

Parameters
msgError message to be written to cerr.

Definition at line 143 of file application.cpp.

Referenced by Application::logerror().

int getUserEnv ( )

Returns an integer specifying the application environment.

Deprecated:

Definition at line 137 of file application.cpp.

Referenced by Application::getUserEnv().

void endLogGroup ( std::string  title)

Close the current group of log messages.

This is typically called just before leaving a function or method, to close the group of messages that were output from this function. Subsequent messages written with addLogEntry() will appear at the next-higher level in the outline, unless beginLogGroup() is called first to create a new group.

Parameters
titleName of the log group. It defaults to the most recent log group created.

Definition at line 222 of file application.cpp.

References AssertThrowMsg, Application::write_logfile(), and Application::writelog().

Referenced by Application::endLogGroup().

void write_logfile ( std::string  file)

Write the HTML log file.

Log entries are stored in memory in an XML tree until this function is called, which writes the tree to a file and clears the entries stored in memory. The output file will have the name specified in the 'file' argument. If this argument has no extension, the extension '.html' will be appended. Also, if the file already exists, an integer will be appended to the name so that no existing log file will be overwritten. WITH_HTML_LOGS must be defined.

Parameters
fileName of the file to be written

Definition at line 253 of file application.cpp.

References Cantera::int2str(), Cantera::npos, and Application::writelog().

Referenced by Application::write_logfile().

Member Data Documentation

std::vector<std::string> errorMessage
protected

Current list of error messages.

Definition at line 284 of file application.h.

Referenced by Application::Messages::operator=(), and Application::Messages::popError().

std::vector<std::string> errorRoutine
protected

Current error Routine.

Definition at line 287 of file application.h.

Referenced by Application::Messages::operator=(), and Application::Messages::popError().

Logger* logwriter
protected

Current pointer to the logwriter.

Definition at line 290 of file application.h.

Referenced by Application::Messages::Messages(), and Application::Messages::operator=().

XML_Node* xmllog
protected

Current pointer to the top of the XML_Node tree for the current HTML log.

Definition at line 293 of file application.h.

Referenced by Application::Messages::operator=().

XML_Node* current
protected

Pointer to the last current position in the XML_Node tree for the current HTML log.

Definition at line 296 of file application.h.

Referenced by Application::Messages::operator=().

int loglevel
protected

Current value of the loglevel.

Definition at line 299 of file application.h.

Referenced by Application::Messages::operator=().

std::vector<int> loglevels
protected

Vector of loglevels for loggroups that are open.

Definition at line 302 of file application.h.

Referenced by Application::Messages::operator=().

std::vector<std::string> loggroups
protected

Current vector of loggroups that are open.

Definition at line 305 of file application.h.

Referenced by Application::Messages::operator=().


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