Class to hold global data. More...
#include <application.h>
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 41 of file 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. | |
void | addError (const string &r, const 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. | |
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 (const string &dir) |
Add a directory to the data file search path. | |
string | findInputFile (const string &name) |
Find an input file. | |
string | getDataDirectories (const string &sep) |
Get the Cantera data directories. | |
void | loadExtension (const string &extType, const string &name) |
Load an extension implementing user-defined models. | |
void | searchPythonVersions (const string &versions) |
Set the versions of Python to try when loading user-defined extensions, in order of preference. | |
void | writelog (const string &msg) |
Write a message to the screen. | |
void | writelogendl () |
Write an endl to the screen and flush output. | |
void | warnlog (const string &warning, const string &msg) |
Write a warning message to the screen. | |
void | warn_deprecated (const string &method, const string &extra="") |
Print a warning indicating that method is deprecated. | |
void | suppress_deprecation_warnings () |
Globally disable printing of deprecation warnings. | |
void | make_deprecation_warnings_fatal () |
Turns deprecation warnings into exceptions. | |
void | warn (const string &warning, const string &method, const string &extra="") |
Generate a general purpose warning; repeated warnings are not suppressed. | |
void | suppress_warnings () |
Globally disable printing of (user) warnings. | |
bool | warnings_suppressed () |
Returns true if warnings should be suppressed. | |
void | make_warnings_fatal () |
Turns Cantera warnings into exceptions. | |
void | suppress_thermo_warnings (bool suppress=true) |
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with discontinuities at the midpoint temperature. | |
bool | thermo_warnings_suppressed () |
Returns true if thermo warnings should be suppressed. | |
void | use_legacy_rate_constants (bool legacy=true) |
Set definition used for rate constant calculation. | |
bool | legacy_rate_constants_used () |
Returns true if legacy rate constant definition is used. | |
void | setLogger (Logger *logwriter) |
Install a logger. | |
void | thread_complete () |
Delete and free memory allocated per thread in multithreaded applications. | |
Static Public Member Functions | |
static Application * | Instance () |
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 shared_ptr< Messages > | pMessages_t |
Typedef for thread specific messages. | |
Protected Member Functions | |
Application () | |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance. | |
void | setDefaultDirectories () |
Set the default directories for input files. | |
Protected Attributes | |
vector< string > | inputDirs |
Current vector of input directories to search for input files. | |
vector< string > | m_pythonSearchVersions |
Versions of Python to consider when attempting to load user extensions. | |
set< string > | warnings |
Set of deprecation warnings that have been emitted (to suppress duplicates) | |
bool | m_suppress_deprecation_warnings = false |
bool | m_fatal_deprecation_warnings = false |
bool | m_suppress_thermo_warnings = false |
bool | m_suppress_warnings = false |
bool | m_fatal_warnings = false |
bool | m_use_legacy_rate_constants = false |
set< pair< string, string > > | m_loaded_extensions |
ThreadMessages | pMessenger |
Static Private Attributes | |
static Application * | s_app = 0 |
Pointer to the single Application instance. | |
|
protected |
Typedef for thread specific messages.
Definition at line 163 of file application.h.
|
protected |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance.
Definition at line 110 of file application.cpp.
|
inlinevirtual |
Destructor for class deletes global data.
Definition at line 203 of file application.h.
|
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 117 of file application.cpp.
|
static |
Static function that destroys the application class's data.
Definition at line 126 of file application.cpp.
|
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 209 of file application.h.
|
inline |
Return the number of errors that have been encountered so far.
Definition at line 214 of file application.h.
|
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 219 of file application.h.
|
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 224 of file application.h.
|
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 229 of file application.h.
|
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 234 of file application.h.
void loadExtension | ( | const string & | extType, |
const string & | name | ||
) |
Load an extension implementing user-defined models.
extType | Specifies the interface / language of the extension, for example "python" |
name | Specifies the name of the extension. The meaning of this parameter depends on the specific extension interface. For example, for Python extensions, this is the name of the Python module containing the models. |
Definition at line 378 of file application.cpp.
void searchPythonVersions | ( | const string & | versions | ) |
Set the versions of Python to try when loading user-defined extensions, in order of preference.
Separate multiple versions with commas, for example "3.11,3.10"
.
Definition at line 429 of file application.cpp.
|
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 305 of file application.h.
|
inline |
Write an endl to the screen and flush output.
Definition at line 310 of file application.h.
|
inline |
Write a warning message to the screen.
warning | String specifying type of warning; see Logger::warn() |
msg | String to be written to the screen |
Definition at line 315 of file application.h.
void warn_deprecated | ( | const string & | method, |
const 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 135 of file application.cpp.
|
inline |
Globally disable printing of deprecation warnings.
Used primarily to prevent certain tests from failing.
Definition at line 327 of file application.h.
|
inline |
Turns deprecation warnings into exceptions.
Activated within the test suite to make sure that no deprecated methods are being used.
Definition at line 334 of file application.h.
void warn | ( | const string & | warning, |
const string & | method, | ||
const string & | extra = "" |
||
) |
Generate a general purpose warning; repeated warnings are not suppressed.
warning | Warning type; see Logger::warn() |
method | Name of method triggering the warning |
extra | Additional information printed for the warning |
Definition at line 146 of file application.cpp.
|
inline |
Globally disable printing of (user) warnings.
Used primarily to prevent certain tests from failing.
Definition at line 346 of file application.h.
|
inline |
Returns true
if warnings should be suppressed.
Definition at line 352 of file application.h.
|
inline |
Turns Cantera warnings into exceptions.
Activated within the test suite to make sure that your warning message are being raised.
Definition at line 358 of file application.h.
|
inline |
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with discontinuities at the midpoint temperature.
Definition at line 364 of file application.h.
|
inline |
Returns true
if thermo warnings should be suppressed.
Definition at line 369 of file application.h.
|
inline |
Set definition used for rate constant calculation.
If set to false
(default value), rate constants of three-body reactions are consistent with conventional definitions (for example Eq. 9.75 in Kee, et al. [17]). If set to true
, output for rate constants of three-body reactions is multiplied by third-body concentrations, consistent with Cantera's behavior prior to version 3.0.
Definition at line 383 of file application.h.
|
inline |
Returns true
if legacy rate constant definition is used.
Definition at line 388 of file application.h.
|
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 393 of file application.h.
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 156 of file application.cpp.
|
protected |
Current vector of input directories to search for input files.
Definition at line 434 of file application.h.
|
protected |
Versions of Python to consider when attempting to load user extensions.
Definition at line 437 of file application.h.
|
protected |
Set of deprecation warnings that have been emitted (to suppress duplicates)
Definition at line 441 of file application.h.
|
protected |
Definition at line 443 of file application.h.
|
protected |
Definition at line 444 of file application.h.
|
protected |
Definition at line 445 of file application.h.
|
protected |
Definition at line 446 of file application.h.
|
protected |
Definition at line 447 of file application.h.
|
protected |
Definition at line 448 of file application.h.
|
protected |
Definition at line 450 of file application.h.
|
protected |
Definition at line 452 of file application.h.
|
staticprivate |
Pointer to the single Application instance.
Definition at line 456 of file application.h.