PetaVision  Alpha
PV::ConfigFileArguments Class Reference

#include <ConfigFileArguments.hpp>

Inheritance diagram for PV::ConfigFileArguments:
PV::Arguments

Public Member Functions

 ConfigFileArguments (std::string const &configFile, MPI_Comm communicator, bool allowUnrecognizedArguments)
 
virtual ~ConfigFileArguments ()
 
bool const & getBooleanArgument (std::string const &name) const
 
int const & getIntegerArgument (std::string const &name) const
 
Configuration::IntOptional const & getIntOptionalArgument (std::string const &name) const
 
std::string const & getStringArgument (std::string const &name) const
 
Configuration::ConfigurationType getType (std::string const &name) const
 
unsigned int const & getUnsignedIntArgument (std::string const &name) const
 
int printState () const
 
void resetState (std::string const &configFile, MPI_Comm communicator, bool allowUnrecognizedArguments)
 
void resetState (std::istream &configStream, bool allowUnrecognizedArguments)
 
void resetState ()
 
bool setBooleanArgument (std::string const &name, bool const &value)
 
bool setIntegerArgument (std::string const &name, int const &value)
 
bool setIntOptionalArgument (std::string const &name, Configuration::IntOptional const &value)
 
bool setStringArgument (std::string const &name, std::string const &value)
 
bool setUnsignedIntArgument (std::string const &name, unsigned int const &value)
 

Protected Member Functions

int initialize (std::string const &configFile, MPI_Comm communicator, bool allowUnrecognizedArguments)
 
int initialize (std::istream &configStream, bool allowUnrecognizedArguments)
 

Private Member Functions

int initialize_base ()
 

Detailed Description

A subclass of Arguments whose constructor takes a filename as an argument. The arguments are passed to initialize(), which calls resetState().

Definition at line 20 of file ConfigFileArguments.hpp.

Constructor & Destructor Documentation

PV::ConfigFileArguments::ConfigFileArguments ( std::string const &  configFile,
MPI_Comm  communicator,
bool  allowUnrecognizedArguments 
)

The constructor for ConfigFileArguments. The given config file is opened as an ifstream and passed to Arguments::initialize().

Definition at line 18 of file ConfigFileArguments.cpp.

virtual PV::ConfigFileArguments::~ConfigFileArguments ( )
inlinevirtual

The destructor for ConfigFileArguments.

Definition at line 35 of file ConfigFileArguments.hpp.

Member Function Documentation

bool const& PV::Arguments::getBooleanArgument ( std::string const &  name) const
inlineinherited

Returns the value of the specified Boolean value in the current configuration. Throws an invalid_argument exception if the input argument does not refer to a Boolean.

Definition at line 62 of file Arguments.hpp.

int const& PV::Arguments::getIntegerArgument ( std::string const &  name) const
inlineinherited

Returns the value of the specified integer in the current configuration. Throws an invalid_argument exception if the input argument does not refer to an integer.

Definition at line 71 of file Arguments.hpp.

Configuration::IntOptional const& PV::Arguments::getIntOptionalArgument ( std::string const &  name) const
inlineinherited

Returns the value of the specified optional integer in the current configuration. Throws an invalid_argument exception if the input argument does not refer to an optional integer.

Definition at line 98 of file Arguments.hpp.

std::string const& PV::Arguments::getStringArgument ( std::string const &  name) const
inlineinherited

Returns the value of the specified string in the current configuration. Throws an invalid_argument exception if the input argument does not refer to a string in the configruation.

Definition at line 89 of file Arguments.hpp.

Configuration::ConfigurationType PV::Arguments::getType ( std::string const &  name) const
inlineinherited

Returns the type for the given string: unrecognized, boolean, integer, unsigned, string, or optional integer.

Definition at line 53 of file Arguments.hpp.

unsigned int const& PV::Arguments::getUnsignedIntArgument ( std::string const &  name) const
inlineinherited

Returns the value of the specified unsigned integer in the current configuration. Throws an invalid_argument exception if the input argument does not refer to an unsigned integer.

Definition at line 80 of file Arguments.hpp.

int PV::ConfigFileArguments::initialize ( std::string const &  configFile,
MPI_Comm  communicator,
bool  allowUnrecognizedArguments 
)
protected

Called by the ConfigFileArguments constructor. It calls resetState with its arguments.

Definition at line 28 of file ConfigFileArguments.cpp.

int PV::Arguments::initialize ( std::istream &  configStream,
bool  allowUnrecognizedArguments 
)
protectedinherited

initialize() is called by the constructor, and calls the resetState(istream, bool) method to set the data members.

Definition at line 27 of file Arguments.cpp.

int PV::ConfigFileArguments::initialize_base ( )
private

initialize_base() is called by the constructor to initialize the internal variables to false for flags, zero for integers, and nullptr for strings.

Definition at line 26 of file ConfigFileArguments.cpp.

int PV::Arguments::printState ( ) const
inherited

Prints the effective command line based on the arguments used in instantiation, and any set-methods used since then.

Definition at line 40 of file Arguments.cpp.

void PV::ConfigFileArguments::resetState ( std::string const &  configFile,
MPI_Comm  communicator,
bool  allowUnrecognizedArguments 
)

resetState is called during instantiation, and can also be called as a public method to discard the results of any set-methods and to use a new file for the base configuration.

The root process of the communicator reads the file specified by configFile into a string, and broadcasts it to the other processes of the communicator. That string is then converted to an input stringstream which is passed to Arguments::resetState.

Definition at line 36 of file ConfigFileArguments.cpp.

void PV::Arguments::resetState ( std::istream &  configStream,
bool  allowUnrecognizedArguments 
)
inherited

Sets the object's state based on the given input stream. The allowUnrecognizedArguments flag has the same effect as in the constructor.

This method creates a ConfigParser object from its arguments, and sets the Arguments data members according to the ConfigParser's get-methods. See ConfigParser::initialize() for a description of how the configuration stream is parsed.

Definition at line 32 of file Arguments.cpp.

void PV::Arguments::resetState ( )
inherited

Resets all member variables to their state at the time the object was instantiated or reinitialized using resetState(istream, bool). That is, the arguments are retrieved from the ConfigParser arguments, and the effect of any set-method that had been called since then is discarded.

Definition at line 38 of file Arguments.cpp.

bool PV::Arguments::setBooleanArgument ( std::string const &  name,
bool const &  value 
)
inlineinherited

Sets the indicated Boolean value in the current configuration to the indicated value. If the configuration does not have a Boolean with the indicated name, the method does nothing.

Definition at line 107 of file Arguments.hpp.

bool PV::Arguments::setIntegerArgument ( std::string const &  name,
int const &  value 
)
inlineinherited

Sets the indicated integer in the current configuration to the indicated value. If the configuration does not have an integer with the indicated name, the method does nothing.

Definition at line 116 of file Arguments.hpp.

bool PV::Arguments::setIntOptionalArgument ( std::string const &  name,
Configuration::IntOptional const &  value 
)
inlineinherited

Sets the indicated optional integer in the current configuration to the indicated value. If the configuration does not have an optional integer with the indicated name, the method does nothing.

Definition at line 143 of file Arguments.hpp.

bool PV::Arguments::setStringArgument ( std::string const &  name,
std::string const &  value 
)
inlineinherited

Sets the indicated string in the current configuration to the indicated value. If the configuration does not have a string with the indicated name, the method does nothing.

Definition at line 134 of file Arguments.hpp.

bool PV::Arguments::setUnsignedIntArgument ( std::string const &  name,
unsigned int const &  value 
)
inlineinherited

Sets the indicated unsigned integer in the current configuration to the indicated value. If the configuration does not have an unsigned integer with the indicated name, the method does nothing.

Definition at line 125 of file Arguments.hpp.


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