#include <source/toolbox/inputdb/InputManager.h>
Public Member Functions | |
virtual Pointer< InputDatabase > | parseInputFile (const std::string &filename) |
virtual void | parseInputFile (const std::string &filename, Pointer< InputDatabase > db) |
Static Public Member Functions | |
static InputManager * | getManager () |
static void | setManager (InputManager *manager) |
static void | freeManager () |
static bool | inputDatabaseExists () |
static Pointer< Database > | getInputDatabase () |
Protected Member Functions | |
InputManager () | |
virtual | ~InputManager () |
All processors must call the parsing routines. Any errors are reported to pout and will result in termination of the program.
The input file will generally have the following format. For each object that requires user specified input, an entry of the following format should be included in the input file.
* Object_entry { * keyword1 = <value1> // maybe some end line comments * keyword2 = <value2> * nested_input_keyword { * nested_data_keyword1 = <value1> * } * \ldots * } *
For convenience, the input parser also supports C/C++ style comments, "include" files, and some expression evaluation.
SAMRAI::tbox::InputManager::InputManager | ( | ) | [protected] |
The constructor is protected, since only subclasses of the singleton may access the constructor. Others may not explicitly create a singleton class.
SAMRAI::tbox::InputManager::~InputManager | ( | ) | [protected, virtual] |
The destructor for the input manager is protected, since only the singleton class and subclasses may destroy the manager objects.
InputManager * SAMRAI::tbox::InputManager::getManager | ( | ) | [static] |
Return a pointer to the single instance of the input manager. All access to the input manager object is through getManager().
void SAMRAI::tbox::InputManager::setManager | ( | InputManager * | manager | ) | [static] |
Set a new input manager. This routine can only be used by subclasses since the constructor and destructor are protected. The manager object will be deleted at program exit.
void SAMRAI::tbox::InputManager::freeManager | ( | ) | [static] |
Deallocate the input manager instance. It is not necessary to call this routine at program termination, since it is automatically called by the SAMRAI shutdown routines.
bool SAMRAI::tbox::InputManager::inputDatabaseExists | ( | ) | [static] |
Return whether or not the manager has read an input database. If so, it returns true. If not, false.
Accessor method for the root input database held by InputManager. Inputs are read from the input file and held in this database. This method returns a pointer to the database, allowing any class in SAMRAI to access the information inside it using standard database calls. For example, the following could appear in a SAMRAI class:
// get root database Pointer<Database> root_db = InputManager::getManager()->getInputDatabase(); // get class's sub-database Pointer<Database> class_db = root_db->getDatabase("MyClass"); // get parameter(s) from sub-database int dummy = class_db->getInteger("dummy");
where "dummy" was supplied in "MyClass" entry of the input file:
MyClass { dummy = ... }
This function is intended for SAMRAI classes in which there is no easy or efficient way to supply input parameters.
Pointer< InputDatabase > SAMRAI::tbox::InputManager::parseInputFile | ( | const std::string & | filename | ) | [virtual] |
Create a new database named "main" from the specified input file.
void SAMRAI::tbox::InputManager::parseInputFile | ( | const std::string & | filename, | |
Pointer< InputDatabase > | db | |||
) | [virtual] |
Parse data from the specified file into the existing database.