Application Class Reference
[Writing HTML LogfilesWriting messages to the screenGlobal Data]

Class to hold global data. More...

Collaboration diagram for Application:
Collaboration graph
[legend]

List of all members.

Classes

class  Messages
 Class to carry out messages. More...
class  ThreadMessages
 Class that stores thread messages for each thread, and retrieves them based on the thread id. More...

Public Member Functions

virtual ~Application ()
 Destructor for class deletes global data.
void setTmpDir (std::string tmp)
 Set the directory where temporary files may be written.
std::string getTmpDir ()
 get the name of a directory where temporary files may be written.
std::string sleep ()
 Pause the application for a certain amount.
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 addDataDirectory (std::string dir)
 Add a directory to the data file search path.
std::string findInputFile (std::string name)
 Find an input file.
XML_Nodeget_XML_File (std::string file, int debug=0)
 Return a pointer to the XML tree for a Cantera input file.
void close_XML_File (std::string file)
 Close an XML File.
void writelog (const std::string &msg)
 Write a message to the screen.
void writelogendl ()
 Write an endl to the screen 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 - Called by the language interfaces to install an appropriate logger.
void thread_complete ()
 Delete Messenger object allocated per thread.
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.

Static Public Member Functions

static ApplicationInstance ()
 Return a pointer to the one and only instance of class Application.
static void ApplicationDestroy ()
 Static function that destroys the application class's data.

Protected Types

typedef boost::shared_ptr
< Messages
pMessages_t
 Typedef for thread specific messages.
typedef std::map< cthreadId_t,
pMessages_t
threadMsgMap_t
 Typedef for map between a thread and the message.

Protected Member Functions

 Application ()
 Constructor for class sets up the initial conditions.
void setDefaultDirectories ()
 Set the default directories for input files.

Protected Attributes

vector< string > inputDirs
 Current vector of input directories to search for input files.
bool stop_on_error
 Current list of error messages.
map< string, string > options
 Current map of options.
string tmp_dir
 Current value of tmp_dir.
map< string, XML_Node * > xmlfiles
 Current vector of xml file trees that have been previously parsed.
string m_sleep
 Current sleep command.
ThreadMessages pMessenger
 Current pointer to the logwriter.

Static Private Attributes

static Applications_app = 0
 Pointer to the single Application instance.

Detailed Description

Class to hold global data.

Class Application is the top-level class that stores data that should persist for the duration of the process. The class should not be instantiated directly; instead, it is instantiated as needed by the functions declared here. At most one instance is created, and it is not destroyed until the process terminates.

Definition at line 165 of file misc.cpp.


Member Typedef Documentation

typedef boost::shared_ptr< Messages > pMessages_t [protected]

Typedef for thread specific messages.

Definition at line 437 of file misc.cpp.

typedef std::map< cthreadId_t, pMessages_t > threadMsgMap_t [protected]

Typedef for map between a thread and the message.

Definition at line 440 of file misc.cpp.


Constructor & Destructor Documentation

Application (  )  [inline, protected]

Constructor for class sets up the initial conditions.

Definition at line 489 of file misc.cpp.

References Application::m_sleep, Application::pMessenger, Application::setDefaultDirectories(), Application::tmp_dir, and Unit::units().

Referenced by Application::Instance().

virtual ~Application (  )  [inline, virtual]

Destructor for class deletes global data.

Delete any open XML trees, the logwriter, and the XML log, if any.

Definition at line 547 of file misc.cpp.

References Application::xmlfiles.


Member Function Documentation

static void ApplicationDestroy (  )  [inline, static]

Static function that destroys the application class's data.

Definition at line 557 of file misc.cpp.

References APP_LOCK, and Application::s_app.

Referenced by Cantera::appdelete().

void close_XML_File ( std::string  file  ) 

Close an XML File.

Close a file that is opened by this application object

Parameters:
file String containing the relative or absolute file name

Definition at line 1075 of file misc.cpp.

References XML_LOCK, and Application::xmlfiles.

Referenced by Cantera::close_XML_File().

XML_Node * get_XML_File ( std::string  file,
int  debug = 0 
)

Return a pointer to the XML tree for a Cantera input file.

This routine will find the file and read the XML file into an XML tree structure. Then, a pointer will be returned. If the file has already been processed, then just the pointer will be returned.

Parameters:
file String containing the relative or absolute file name
debug Debug flag

Definition at line 947 of file misc.cpp.

References ctml::ct2ctml(), Application::findInputFile(), XML_LOCK, and Application::xmlfiles.

Referenced by Cantera::get_XML_File(), Cantera::get_XML_NameID(), and Cantera::get_XML_Node().

int getErrorCount (  )  [inline]

Return the number of errors that have been encountered so far.

Definition at line 596 of file misc.cpp.

References Application::pMessenger.

Referenced by Cantera::nErrors().

std::string getTmpDir (  ) 

get the name of a directory where temporary files may be written.

Definition at line 1101 of file misc.cpp.

References APP_LOCK, and Application::tmp_dir.

Referenced by Cantera::tmpDir().

int getUserEnv (  )  [inline]

Returns an integer specifying the application environment.

Definition at line 746 of file misc.cpp.

References Application::pMessenger.

Referenced by Cantera::userInterface().

static Application* Instance (  )  [inline, static]

Return a pointer to the one and only instance of class Application.

Definition at line 534 of file misc.cpp.

References APP_LOCK, Application::Application(), and Application::s_app.

Referenced by Cantera::app().

void logerror ( const std::string &  msg  )  [inline]

Write an error message and quit.

The default behavior is to write to the standard eror 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:
msg Error message to be written to cerr.

Definition at line 743 of file misc.cpp.

References Application::pMessenger.

Referenced by Cantera::error().

void setTmpDir ( std::string  tmp  ) 

Set the directory where temporary files may be written.

Parameters:
tmp Name of the directory

Definition at line 1095 of file misc.cpp.

References APP_LOCK, and Application::tmp_dir.

Referenced by Cantera::setTmpDir().

std::string sleep (  ) 

Pause the application for a certain amount.

This has been needed in the past for some network file systems.

Definition at line 1107 of file misc.cpp.

References APP_LOCK, and Application::m_sleep.

Referenced by Cantera::sleep().

void thread_complete (  ) 

Delete Messenger object allocated per thread.

Definition at line 935 of file misc.cpp.

References Application::pMessenger, and ThreadMessages::removeThreadMessages().

Referenced by Cantera::thread_complete().

void write_logfile ( std::string  file  )  [inline]

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:
file Name of the file to be written

Definition at line 847 of file misc.cpp.

References Application::pMessenger.

Referenced by Cantera::write_logfile().


Member Data Documentation

vector<string> inputDirs [protected]

Current vector of input directories to search for input files.

Definition at line 854 of file misc.cpp.

Referenced by Application::addDataDirectory(), Application::findInputFile(), and Application::setDefaultDirectories().

string m_sleep [protected]

Current sleep command.

Definition at line 874 of file misc.cpp.

Referenced by Application::Application(), and Application::sleep().

map<string, string> options [protected]

Current map of options.

Definition at line 868 of file misc.cpp.

Current pointer to the logwriter.

Current pointer to the top of the XML_Node tree for the current HTML log Pointer to the last current position in the XML_Node tree for the current HTML log Current value of loglevel Vector of loglevels for loggroups that are open Current vector of loggroups that are open

Definition at line 891 of file misc.cpp.

Referenced by Application::addError(), Application::addLogEntry(), Application::Application(), Application::beginLogGroup(), Application::endLogGroup(), Application::getErrorCount(), Application::getErrors(), Application::getUserEnv(), Application::lastErrorMessage(), Application::logerror(), Application::logErrors(), Application::popError(), Application::setLogger(), Application::thread_complete(), Application::write_logfile(), Application::writelog(), and Application::writelogendl().

Application * s_app = 0 [static, private]

Pointer to the single Application instance.

Definition at line 897 of file misc.cpp.

Referenced by Application::ApplicationDestroy(), and Application::Instance().

bool stop_on_error [protected]

Current list of error messages.

Current list of warning messages Current error Routine Last error message Current line length Current value of stop_on_error

Definition at line 866 of file misc.cpp.

string tmp_dir [protected]

Current value of tmp_dir.

Definition at line 870 of file misc.cpp.

Referenced by Application::Application(), Application::getTmpDir(), and Application::setTmpDir().

map<string, XML_Node*> xmlfiles [protected]

Current vector of xml file trees that have been previously parsed.

Definition at line 872 of file misc.cpp.

Referenced by Application::close_XML_File(), Application::get_XML_File(), and Application::~Application().


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.3