CommandLineArguments Class Reference

#include <CommandLineArguments.hpp>

Collaboration diagram for CommandLineArguments:

Collaboration graph
[legend]

List of all members.

Public Member Functions

bool OptionExists (std::string option)
char * GetValueCorrespondingToOption (std::string option)

Static Public Member Functions

static CommandLineArgumentsInstance ()

Public Attributes

int * p_argc
char *** p_argv

Private Member Functions

 CommandLineArguments ()
 CommandLineArguments (const CommandLineArguments &)
CommandLineArgumentsoperator= (const CommandLineArguments &)
int GetIndexForArgument (std::string argument)

Static Private Attributes

static CommandLineArgumentsmpInstance = NULL


Detailed Description

A convenient holder for the command line arguments, with a couple of helper methods for checking whether an option has been given or getting the value corresponding to a given option.

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 44 of file CommandLineArguments.hpp.


Constructor & Destructor Documentation

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.


Member Function Documentation

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  )  [inline]

Check whether a given option exists in the command line arguments.

Parameters:
option The option as a string. This should start with "-", for example "-implicit_scheme" "-no_output" etc.

Definition at line 62 of file CommandLineArguments.hpp.

References GetIndexForArgument().

char* CommandLineArguments::GetValueCorrespondingToOption ( std::string  option  )  [inline]

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.

Parameters:
option The option as a string. This should start with "-", for example "-my_param" "-timestep" etc.

Definition at line 83 of file CommandLineArguments.hpp.

References EXCEPTION, GetIndexForArgument(), p_argc, and p_argv.

CommandLineArguments& CommandLineArguments::operator= ( const CommandLineArguments  )  [private]

Overloaded assignment operator.

int CommandLineArguments::GetIndexForArgument ( std::string  argument  )  [inline, private]

Get the index for the given argument. Returns -1 if the argument is not found.

Parameters:
argument The argument as a string. This should start with "-", for example "-my_arg" "-timestep" etc.

Definition at line 118 of file CommandLineArguments.hpp.

References p_argc, and p_argv.

Referenced by GetValueCorrespondingToOption(), and OptionExists().


Member Data Documentation

The number of command line arguments.

Definition at line 49 of file CommandLineArguments.hpp.

Referenced by GetIndexForArgument(), GetValueCorrespondingToOption(), ExecutableSupport::InitializePetsc(), and PetscSetup::setUpWorld().

The single instance of the class.

Definition at line 111 of file CommandLineArguments.hpp.

Referenced by CommandLineArguments(), and Instance().


The documentation for this class was generated from the following files:

Generated on Mon Nov 1 12:36:25 2010 for Chaste by  doxygen 1.5.5