Skip to content

Commit

Permalink
Merge pull request #640 from briadam/options_handling_569
Browse files Browse the repository at this point in the history
More granular options parsing for Environment
  • Loading branch information
roystgnr authored Oct 17, 2017
2 parents 5803bf2 + 4d3fa43 commit 469911a
Show file tree
Hide file tree
Showing 22 changed files with 1,853 additions and 1,628 deletions.
65 changes: 57 additions & 8 deletions src/core/inc/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,27 @@ class BaseEnvironment {
//! @name Constructor/Destructor methods
//@{
//! Default constructor.
BaseEnvironment(const char* passedOptionsInputFileName, EnvOptionsValues* alternativeOptionsValues);
/*!
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
BaseEnvironment(const char* passedOptionsInputFileName, EnvOptionsValues* initialOptionsValues);

//! Alternate constructor.
/*!
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
BaseEnvironment(const std::string & passedOptionsInputFileName,
EnvOptionsValues* alternativeOptionsValues);
EnvOptionsValues* initialOptionsValues);

//! Destructor
/*! It deallocates memory and does other cleanup for the class object and its class members when
Expand Down Expand Up @@ -456,7 +473,7 @@ class EmptyEnvironment : public BaseEnvironment {
//! @name Constructor/Destructor methods
//@{
//! Default constructor. Does nothing.
/*! It initialized BaseEnvironment with no input file and a NULL pointer for the alternativeOptionsValues.*/
/*! It initializes BaseEnvironment with no input file and default options */
EmptyEnvironment();

//! Destructor
Expand Down Expand Up @@ -484,26 +501,58 @@ class FullEnvironment : public BaseEnvironment {
* Initializes the full communicator, reads the options, deals with multiple
* sub-environments, e.g. dealing with sub/self/inter0-communicators, handles
* path for output files.
*
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
#ifdef QUESO_HAS_MPI
FullEnvironment(RawType_MPI_Comm inputComm, const char* passedOptionsInputFileName, const char* prefix, EnvOptionsValues* alternativeOptionsValues);
FullEnvironment(RawType_MPI_Comm inputComm, const char* passedOptionsInputFileName, const char* prefix, EnvOptionsValues* initialOptionsValues);

//! Parallel constructor.
/*!
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
FullEnvironment(RawType_MPI_Comm inputComm,
const std::string& passedOptionsInputFileName,
const std::string& prefix,
EnvOptionsValues* alternativeOptionsValues);
EnvOptionsValues* initialOptionsValues);
#endif

//! Serial constructor.
/*!
* No communicator is passed. Output path handling is exactly as in the
* parallel ctor.
*
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
FullEnvironment(const char* passedOptionsInputFileName, const char* prefix, EnvOptionsValues* alternativeOptionsValues);
FullEnvironment(const char* passedOptionsInputFileName, const char* prefix, EnvOptionsValues* initialOptionsValues);

//! Serial constructor.
/*!
* initialOptionsValues apply first, followed by any overrides
* present in passedOptionsInputFileName. Historically the behavior was:
* IF alternative options passed in, use them exclusively
* ELSE IF input file, parse and set options from it
* ELSE use default options
* so the input file was ignored when options object was passed in.
*/
FullEnvironment(const std::string& passedOptionsInputFileName,
const std::string& prefix,
EnvOptionsValues* alternativeOptionsValues);
EnvOptionsValues* initialOptionsValues);

//! Destructor
~FullEnvironment();
Expand All @@ -526,7 +575,7 @@ class FullEnvironment : public BaseEnvironment {
void construct(const char *prefix);

//! Checks the options input file and reads the options.
void readOptionsInputFile();
void readOptionsInputFile(const std::string& prefix);
//void queso_terminate_handler();

};
Expand Down
9 changes: 9 additions & 0 deletions src/core/inc/EnvironmentOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ class EnvOptionsValues
//! Copy constructor
EnvOptionsValues(const EnvOptionsValues& src);

//! Set parameter option names to begin with prefix
void set_prefix(const std::string& prefix);

//! Set default values for parameter options
void set_defaults();

//! Given prefix, read the input file for parameters named "prefix"+*
void parse(const BaseEnvironment& env, const std::string& prefix);

//! Destructor
virtual ~EnvOptionsValues();
//@}
Expand Down
16 changes: 14 additions & 2 deletions src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,21 @@ namespace QUESO {
class InfiniteDimensionalMCMCSamplerOptions
{
public:
//! Constructor
InfiniteDimensionalMCMCSamplerOptions();

//! Given prefix, read the input file for parameters named prefix_*
InfiniteDimensionalMCMCSamplerOptions(const BaseEnvironment& env, const char* prefix);

//! Set default values for parameter options
void set_defaults();

//! Set parameter option names to begin with prefix
void set_prefix(const std::string& prefix);

//! Given prefix, read the input file for parameters named "prefix"+*
void parse(const BaseEnvironment& env, const std::string& prefix);

//! Destructor
virtual ~InfiniteDimensionalMCMCSamplerOptions();

Expand Down Expand Up @@ -86,10 +98,10 @@ class InfiniteDimensionalMCMCSamplerOptions

private:
#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
BoostInputOptionsParser * m_parser;
ScopedPtr<BoostInputOptionsParser>::Type m_parser;
#endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS

const BaseEnvironment& m_env;
const BaseEnvironment* m_env;

std::string m_option_help;
std::string m_option_dataOutputDirName;
Expand Down
13 changes: 12 additions & 1 deletion src/core/inc/OptimizerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class OptimizerOptions
//! Copy constructor
OptimizerOptions(const OptimizerOptions & rhs);

//! Set default values for parameter options
void set_defaults();

//! Set parameter option names to begin with prefix
void set_prefix(const std::string& prefix);

//! Given prefix, read the input file for parameters named "prefix"+*
void parse(const BaseEnvironment& env, const std::string& prefix);

//! Destructor
virtual ~OptimizerOptions();
//@}
Expand Down Expand Up @@ -135,7 +144,9 @@ class OptimizerOptions
private:
const BaseEnvironment * m_env;

BoostInputOptionsParser * m_parser;
#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
ScopedPtr<BoostInputOptionsParser>::Type m_parser;
#endif

// The input options as strings so we can parse the input file later
std::string m_option_help;
Expand Down
Loading

0 comments on commit 469911a

Please sign in to comment.