#include <CommandLineArguments.hpp>
Public Member Functions | |
bool | OptionExists (std::string option) |
char * | GetValueCorrespondingToOption (std::string option) |
double | GetDoubleCorrespondingToOption (std::string option) |
int | GetIntCorrespondingToOption (std::string option) |
unsigned | GetUnsignedCorrespondingToOption (std::string option) |
Static Public Member Functions | |
static CommandLineArguments * | Instance () |
Public Attributes | |
int * | p_argc |
char *** | p_argv |
Private Member Functions | |
CommandLineArguments () | |
CommandLineArguments (const CommandLineArguments &) | |
CommandLineArguments & | operator= (const CommandLineArguments &) |
int | GetIndexForArgument (std::string argument) |
Static Private Attributes | |
static CommandLineArguments * | mpInstance = NULL |
The cxxtest harness will fill in the member variables when a test is started. They can then be read by PETSc when it is initialised.
Definition at line 42 of file CommandLineArguments.hpp.
CommandLineArguments::CommandLineArguments | ( | ) | [private] |
Default constructor. Should never be called directly, call CommandLineArguments::Instance() instead.
Definition at line 34 of file CommandLineArguments.cpp.
References mpInstance.
CommandLineArguments::CommandLineArguments | ( | const CommandLineArguments & | ) | [private] |
Copy constructor.
CommandLineArguments& CommandLineArguments::operator= | ( | const CommandLineArguments & | ) | [private] |
Overloaded assignment operator.
int CommandLineArguments::GetIndexForArgument | ( | std::string | argument | ) | [private] |
Get the index for the given argument. Returns -1 if the argument is not found.
argument | The argument as a string. This should start with "-", for example "-my_arg" "-timestep" etc. |
Definition at line 100 of file CommandLineArguments.cpp.
References p_argc, and p_argv.
Referenced by GetValueCorrespondingToOption(), and OptionExists().
CommandLineArguments * CommandLineArguments::Instance | ( | ) | [static] |
Get the single instance of this class.
Definition at line 42 of file CommandLineArguments.cpp.
References mpInstance.
Referenced by ExecutableSupport::InitializePetsc(), and PetscSetup::setUpWorld().
bool CommandLineArguments::OptionExists | ( | std::string | option | ) |
Check whether a given option exists in the command line arguments.
option | The option as a string. This should start with "-", for example "-implicit_scheme" "-no_output" etc. |
Definition at line 53 of file CommandLineArguments.cpp.
References GetIndexForArgument().
char * CommandLineArguments::GetValueCorrespondingToOption | ( | std::string | option | ) |
Get the value for a given option, ie the argument after the option name in the list of command line arguments. For example, if the following arguments were given ./heart/build/debug/TestMyClassRunner -timestep 0.04 Then calling CommandLineArguments::Instance()->GetValueCorrespondingToOption("-timestep"); will return 0.04 (as a char*). Use atoi or atof to convert the char* to an int or a double(float) respectively.
option | The option as a string. This should start with "-", for example "-my_param" "-timestep" etc. |
Definition at line 61 of file CommandLineArguments.cpp.
References EXCEPTION, GetIndexForArgument(), p_argc, and p_argv.
Referenced by GetDoubleCorrespondingToOption(), GetIntCorrespondingToOption(), and GetUnsignedCorrespondingToOption().
double CommandLineArguments::GetDoubleCorrespondingToOption | ( | std::string | option | ) |
Get the double for a given option.
This uses GetValueCorrespondingToOption and converts the char* to a double.
option | The option as a string. This should start with "-", for example "-my_param", "-timestep" etc. |
Definition at line 77 of file CommandLineArguments.cpp.
References GetValueCorrespondingToOption().
int CommandLineArguments::GetIntCorrespondingToOption | ( | std::string | option | ) |
Get the int for a given option.
This uses GetValueCorrespondingToOption and converts the char* to an int.
option | The option as a string. This should start with "-", for example "-my_param", "-timestep" etc. |
Definition at line 83 of file CommandLineArguments.cpp.
References GetValueCorrespondingToOption().
unsigned CommandLineArguments::GetUnsignedCorrespondingToOption | ( | std::string | option | ) |
Get the unsigned for a given option.
This uses GetValueCorrespondingToOption and converts the char* to an unsigned. Throws an exception if the option converts to a negative integer.
option | The option as a string. This should start with "-", for example "-my_param", "-timestep" etc. |
Definition at line 89 of file CommandLineArguments.cpp.
References EXCEPTION, and GetValueCorrespondingToOption().
CommandLineArguments * CommandLineArguments::mpInstance = NULL [static, private] |
The single instance of the class.
Definition at line 55 of file CommandLineArguments.hpp.
Referenced by CommandLineArguments(), and Instance().
The number of command line arguments.
Definition at line 67 of file CommandLineArguments.hpp.
Referenced by GetIndexForArgument(), GetValueCorrespondingToOption(), ExecutableSupport::InitializePetsc(), and PetscSetup::setUpWorld().
char*** CommandLineArguments::p_argv |
The arguments themselves.
Definition at line 70 of file CommandLineArguments.hpp.
Referenced by GetIndexForArgument(), GetValueCorrespondingToOption(), ExecutableSupport::InitializePetsc(), and PetscSetup::setUpWorld().