Cantera
2.3.0
|
Class to hold global data. More...
#include <application.h>
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. More... | |
void | addError (const std::string &r, const std::string &msg="") |
Set an error condition in the application class without throwing an exception. More... | |
int | getErrorCount () |
Return the number of errors that have been encountered so far. More... | |
void | popError () |
Discard the last error message. More... | |
std::string | lastErrorMessage () |
Retrieve the last error message in a string. More... | |
void | getErrors (std::ostream &f) |
Prints all of the error messages to an ostream. More... | |
void | logErrors () |
Prints all of the error messages using writelog. More... | |
void | addDataDirectory (const std::string &dir) |
Add a directory to the data file search path. More... | |
std::string | findInputFile (const std::string &name) |
Find an input file. More... | |
std::string | getDataDirectories (const std::string &sep) |
Get the Cantera data directories. More... | |
XML_Node * | get_XML_File (const std::string &file, int debug=0) |
Return a pointer to the XML tree for a Cantera input file. More... | |
XML_Node * | get_XML_from_string (const std::string &text) |
Read a CTI or CTML string and fill up an XML tree. More... | |
void | close_XML_File (const std::string &file) |
Close an XML File. More... | |
void | writelog (const std::string &msg) |
Write a message to the screen. More... | |
void | writelogendl () |
Write an endl to the screen and flush output. More... | |
void | warn_deprecated (const std::string &method, const std::string &extra="") |
Print a warning indicating that method is deprecated. More... | |
void | suppress_deprecation_warnings () |
Globally disable printing of deprecation warnings. More... | |
void | make_deprecation_warnings_fatal () |
Turns deprecation warnings into exceptions. More... | |
void | suppress_thermo_warnings (bool suppress=true) |
Globally disable printing of warnings about problematic thermo data, e.g. More... | |
bool | thermo_warnings_suppressed () |
Returns true if thermo warnings should be suppressed. More... | |
void | setLogger (Logger *logwriter) |
Install a logger. More... | |
void | thread_complete () |
Delete and free memory allocated per thread in multithreaded applications. More... | |
Static Public Member Functions | |
static Application * | Instance () |
Return a pointer to the one and only instance of class Application. More... | |
static void | ApplicationDestroy () |
Static function that destroys the application class's data. More... | |
Protected Types | |
typedef shared_ptr< Messages > | pMessages_t |
Typedef for thread specific messages. More... | |
Protected Member Functions | |
Application () | |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance. More... | |
void | setDefaultDirectories () |
Set the default directories for input files. More... | |
Protected Attributes | |
std::vector< std::string > | inputDirs |
Current vector of input directories to search for input files. More... | |
std::map< std::string, std::pair< XML_Node *, int > > | xmlfiles |
Current vector of XML file trees that have been previously parsed The second element of the value is used to store the last-modified time for the file, to enable change detection. More... | |
std::set< std::string > | warnings |
Vector of deprecation warnings that have been emitted (to suppress duplicates) More... | |
bool | m_suppress_deprecation_warnings |
bool | m_fatal_deprecation_warnings |
bool | m_suppress_thermo_warnings |
ThreadMessages | pMessenger |
Static Private Attributes | |
static Application * | s_app = 0 |
Pointer to the single Application instance. More... | |
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 44 of file application.h.
|
protected |
Typedef for thread specific messages.
Definition at line 158 of file application.h.
|
protected |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance.
Definition at line 126 of file application.cpp.
References Application::setDefaultDirectories(), and Unit::units().
Referenced by Application::Instance().
|
virtual |
Destructor for class deletes global data.
Deletes any open XML trees.
Definition at line 146 of file application.cpp.
References Application::xmlfiles.
|
static |
Return a pointer to the one and only instance of class Application.
If the Application object has not yet been created, it is created
Definition at line 137 of file application.cpp.
References Cantera::app_mutex, Application::Application(), and Application::s_app.
Referenced by CanteraError::save().
|
static |
Static function that destroys the application class's data.
Definition at line 155 of file application.cpp.
References Cantera::app_mutex, and Application::s_app.
|
inline |
Set an error condition in the application class without throwing an exception.
This routine adds an error message to the end of the stack of errors that Cantera accumulates in the Application class.
r | Procedure name which is generating the error condition |
msg | Descriptive message of the error condition. |
If only one argument is specified, that string is used as the entire message.
Definition at line 207 of file application.h.
References Application::Messages::addError().
Referenced by CanteraError::save(), and Cantera::setError().
|
inline |
Return the number of errors that have been encountered so far.
Definition at line 212 of file application.h.
References Application::Messages::getErrorCount().
Referenced by Cantera::nErrors().
|
inline |
Discard the last error message.
Cantera saves a stack of exceptions that it has caught in the Application class. This routine eliminates the last exception to be added to that stack.
Definition at line 217 of file application.h.
References Application::Messages::popError().
Referenced by Cantera::popError().
|
inline |
Retrieve the last error message in a string.
This routine will retrieve the last error message and return it in the return string.
Definition at line 222 of file application.h.
References Application::Messages::lastErrorMessage().
Referenced by Cantera::lastErrorMessage().
|
inline |
Prints all of the error messages to an ostream.
Write out all of the saved error messages to the ostream f using the function Logger::writelog. Cantera saves a stack of exceptions that it has caught in the Application class. This routine writes out all of the error messages to the ostream and then clears them from internal storage.
f | ostream which will receive the error messages |
Definition at line 227 of file application.h.
References Application::Messages::getErrors().
Referenced by Cantera::showErrors().
|
inline |
Prints all of the error messages using writelog.
Print all of the error messages using function writelog. Cantera saves a stack of exceptions that it has caught in the Application class. This routine writes out all of the error messages and then clears them from internal storage.
Definition at line 232 of file application.h.
References Application::Messages::logErrors().
Referenced by Cantera::showErrors().
XML_Node * get_XML_File | ( | const 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.
file | String containing the relative or absolute file name |
debug | Debug flag |
Definition at line 182 of file application.cpp.
References Application::findInputFile(), and Cantera::xml_mutex.
Referenced by Cantera::get_XML_File().
XML_Node * get_XML_from_string | ( | const std::string & | text | ) |
Read a CTI or CTML string and fill up an XML tree.
Return a pointer to the XML tree corresponding to the specified CTI or XML string. If the given string has been processed before, the cached XML tree will be returned. Otherwise, the XML tree will be generated and stored in the cache.
text | CTI or CTML string |
Definition at line 219 of file application.cpp.
References Cantera::ct_string2ctml_string(), Cantera::xml_mutex, and Application::xmlfiles.
Referenced by Cantera::get_XML_from_string().
void close_XML_File | ( | const std::string & | file | ) |
Close an XML File.
Close a file that is opened by this application object
file | String containing the relative or absolute file name |
Definition at line 239 of file application.cpp.
References Cantera::xml_mutex, and Application::xmlfiles.
Referenced by Cantera::close_XML_File().
|
inline |
Write a message to the screen.
The string may be of any length, and may contain end-of-line characters. This method is used throughout Cantera to write log messages. It can also be called by user programs. The advantage of using writelog over writing directly to the standard output is that messages written with writelog will display correctly even when Cantera is used from MATLAB or other application that do not have a standard output stream.
msg | c++ string to be written to the screen |
Definition at line 320 of file application.h.
References Application::Messages::writelog().
Referenced by Application::Messages::logErrors(), Application::warn_deprecated(), and Cantera::writelog_direct().
|
inline |
Write an endl to the screen and flush output.
Definition at line 325 of file application.h.
References Application::Messages::writelogendl().
Referenced by Application::Messages::logErrors(), Application::warn_deprecated(), and Cantera::writelogendl().
void warn_deprecated | ( | const std::string & | method, |
const std::string & | extra = "" |
||
) |
Print a warning indicating that method is deprecated.
Additional information (removal version, alternatives) can be specified in extra. Deprecation warnings are printed once per method per invocation of the application.
Definition at line 164 of file application.cpp.
References Application::warnings, Application::writelog(), and Application::writelogendl().
Referenced by Cantera::warn_deprecated().
|
inline |
Globally disable printing of deprecation warnings.
Used primarily to prevent certain tests from failing.
Definition at line 337 of file application.h.
Referenced by Cantera::suppress_deprecation_warnings().
|
inline |
Turns deprecation warnings into exceptions.
Activated within the test suite to make sure that no deprecated methods are being used.
Definition at line 343 of file application.h.
Referenced by Cantera::make_deprecation_warnings_fatal().
|
inline |
Globally disable printing of warnings about problematic thermo data, e.g.
NASA polynomials with discontinuities at the midpoint temperature.
Definition at line 349 of file application.h.
Referenced by Cantera::suppress_thermo_warnings().
|
inline |
Returns true
if thermo warnings should be suppressed.
Definition at line 354 of file application.h.
Referenced by Cantera::thermo_warnings_suppressed().
|
inline |
Install a logger.
Called by the language interfaces to install an appropriate logger. The logger is used for the writelog() function
logwriter | Pointer to a logger object |
Definition at line 359 of file application.h.
References Application::Messages::setLogger().
Referenced by Cantera::setLogger().
void thread_complete | ( | ) |
Delete and free memory allocated per thread in multithreaded applications.
Delete the memory allocated per thread by Cantera. It should be called from within the thread just before the thread terminates. If your version of Cantera has not been specifically compiled for thread safety this function does nothing.
Definition at line 177 of file application.cpp.
References Application::ThreadMessages::removeThreadMessages().
Referenced by Cantera::thread_complete().
|
protected |
Current vector of input directories to search for input files.
Definition at line 402 of file application.h.
Referenced by Application::addDataDirectory(), Application::findInputFile(), Application::getDataDirectories(), and Application::setDefaultDirectories().
|
protected |
Current vector of XML file trees that have been previously parsed The second element of the value is used to store the last-modified time for the file, to enable change detection.
Definition at line 407 of file application.h.
Referenced by Application::close_XML_File(), Application::get_XML_from_string(), and Application::~Application().
|
protected |
Vector of deprecation warnings that have been emitted (to suppress duplicates)
Definition at line 410 of file application.h.
Referenced by Application::warn_deprecated().
|
staticprivate |
Pointer to the single Application instance.
Definition at line 420 of file application.h.
Referenced by Application::ApplicationDestroy(), and Application::Instance().