PetaVision  Alpha
PV::Arguments Class Reference

#include <Arguments.hpp>

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

Public Member Functions

 Arguments (std::istream &configStream, bool allowUnrecognizedArguments)
 
virtual ~Arguments ()
 
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::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

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

Private Member Functions

int initialize_base ()
 

Private Attributes

ConfigParsermConfigFromStream = nullptr
 
Configuration mCurrentConfig
 

Detailed Description

A class for parsing a configuration and storing the results. Internally, the Arguments object contains a require-return flag, an output path string, a params file string, a log file string, a gpu devices string, a working directory string, a checkpointRead directory string, a restart flag, an unsigned integer indicating a random seed, and integers indicating the number of threads, the number of MPI rows, the number of MPI columns, and the batch width. After initialization, individual settings can be modified with set-methods, or reset to the original settings.

It is an error to set both the restart flag and the checkpointRead directory string. Arguments does not check whether directory strings point at existing directories, or do any other sanity checking of the arguments. Typically under MPI, each mpi process will call PV_Init with the same arguments, and each process's PV_Init object creates a Arguments object that it, HyPerCol, and other objects can use to get the configuration arguments.

Definition at line 37 of file Arguments.hpp.

Constructor & Destructor Documentation

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

The constructor for Arguments. The arguments are passed to initialize().

Definition at line 20 of file Arguments.cpp.

PV::Arguments::~Arguments ( )
virtual

The destructor for Arguments.

Definition at line 45 of file Arguments.cpp.

PV::Arguments::Arguments ( )
inlineprotected

The constructor that should be called by classes derived from Arguments. It calls initialize_base() but not initialize. The derived class's own initialization should call Arguments::initialize().

Definition at line 180 of file Arguments.hpp.

Member Function Documentation

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

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
inline

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
inline

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
inline

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
inline

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
inline

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::Arguments::initialize ( std::istream &  configStream,
bool  allowUnrecognizedArguments 
)
protected

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::Arguments::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 25 of file Arguments.cpp.

int PV::Arguments::printState ( ) const

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::Arguments::resetState ( std::istream &  configStream,
bool  allowUnrecognizedArguments 
)

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 ( )

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

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

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

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

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

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: