From 4d3fa43903a17a82a93c900448c0b4b2d5bebb2c Mon Sep 17 00:00:00 2001
From: "Brian M. Adams" <briadam@sandia.gov>
Date: Mon, 16 Oct 2017 13:35:59 -0600
Subject: [PATCH] Granular Options handling: cleanup pass

Finish up #569:
 * Add default ctor to all Options classes and always init defaults
   and m_env
 * Always initialize BoostInputOptionsParser since operator<< may
   dereference it (there remains a bug w.r.t. same in copy ctors, but
   not going to take time on it as no current use cases and code is
   deprecated)
---
 src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h |  3 +++
 src/core/src/EnvironmentOptions.C                    |  3 +++
 src/core/src/InfiniteDimensionalMCMCSamplerOptions.C | 11 +++++++++++
 src/core/src/OptimizerOptions.C                      |  3 +++
 src/stats/inc/MLSamplingLevelOptions.h               |  3 +++
 src/stats/inc/MLSamplingOptions.h                    |  3 +++
 src/stats/src/MLSamplingLevelOptions.C               | 11 +++++++++++
 src/stats/src/MLSamplingOptions.C                    | 11 +++++++++++
 src/stats/src/MetropolisHastingsSGOptions.C          |  3 +++
 src/stats/src/MonteCarloSGOptions.C                  |  3 +++
 src/stats/src/StatisticalForwardProblemOptions.C     |  3 +++
 src/stats/src/StatisticalInverseProblemOptions.C     |  3 +++
 12 files changed, 60 insertions(+)

diff --git a/src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h b/src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h
index 74806de31..419ace2f2 100644
--- a/src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h
+++ b/src/core/inc/InfiniteDimensionalMCMCSamplerOptions.h
@@ -47,6 +47,9 @@ namespace QUESO {
 class InfiniteDimensionalMCMCSamplerOptions
 {
 public:
+  //! Constructor
+  InfiniteDimensionalMCMCSamplerOptions();
+
   //! Given prefix, read the input file for parameters named prefix_*
   InfiniteDimensionalMCMCSamplerOptions(const BaseEnvironment& env, const char* prefix);
 
diff --git a/src/core/src/EnvironmentOptions.C b/src/core/src/EnvironmentOptions.C
index 16890cace..ecbcc6ea0 100644
--- a/src/core/src/EnvironmentOptions.C
+++ b/src/core/src/EnvironmentOptions.C
@@ -47,6 +47,9 @@ namespace QUESO {
 EnvOptionsValues::EnvOptionsValues()
   :
   m_env(NULL)
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  , m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
   this->set_defaults();
   this->set_prefix("");
diff --git a/src/core/src/InfiniteDimensionalMCMCSamplerOptions.C b/src/core/src/InfiniteDimensionalMCMCSamplerOptions.C
index 6b5adaeb0..a0545aac2 100644
--- a/src/core/src/InfiniteDimensionalMCMCSamplerOptions.C
+++ b/src/core/src/InfiniteDimensionalMCMCSamplerOptions.C
@@ -33,6 +33,17 @@
 
 namespace QUESO {
 
+InfiniteDimensionalMCMCSamplerOptions::InfiniteDimensionalMCMCSamplerOptions()
+  :
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  m_parser(new BoostInputOptionsParser()),
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  m_env(NULL)
+{
+  this->set_defaults();
+  this->set_prefix("");
+}
+
 InfiniteDimensionalMCMCSamplerOptions::InfiniteDimensionalMCMCSamplerOptions(
     const BaseEnvironment& env,
     const char * prefix)
diff --git a/src/core/src/OptimizerOptions.C b/src/core/src/OptimizerOptions.C
index 1e71918fa..fa4d4f91d 100644
--- a/src/core/src/OptimizerOptions.C
+++ b/src/core/src/OptimizerOptions.C
@@ -40,6 +40,9 @@ namespace QUESO {
 OptimizerOptions::OptimizerOptions()
   : 
   m_env(NULL)
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  , m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
   this->set_defaults();
   this->set_prefix("");
diff --git a/src/stats/inc/MLSamplingLevelOptions.h b/src/stats/inc/MLSamplingLevelOptions.h
index a49b12284..6c26f3644 100644
--- a/src/stats/inc/MLSamplingLevelOptions.h
+++ b/src/stats/inc/MLSamplingLevelOptions.h
@@ -129,6 +129,9 @@ class MLSamplingLevelOptions
 public:
   //! @name Constructor/Destructor methods
   //@{
+  //! Constructor
+  MLSamplingLevelOptions();
+
   //! Constructor: reads options from the input file.
   MLSamplingLevelOptions(const BaseEnvironment& env, const char* prefix);
 
diff --git a/src/stats/inc/MLSamplingOptions.h b/src/stats/inc/MLSamplingOptions.h
index e93a1825c..e252f350e 100644
--- a/src/stats/inc/MLSamplingOptions.h
+++ b/src/stats/inc/MLSamplingOptions.h
@@ -76,6 +76,9 @@ class MLSamplingOptions
   //@{
   //! Default constructor.
   /*! Assigns the default suite of options to the Multilevel sequence generator.*/
+  MLSamplingOptions();
+
+  //! Parsing constructor.
   MLSamplingOptions(const BaseEnvironment& env, const char* prefix);
 
   //! Set default values for parameter options
diff --git a/src/stats/src/MLSamplingLevelOptions.C b/src/stats/src/MLSamplingLevelOptions.C
index 6cf7f96d3..03cb56b1f 100644
--- a/src/stats/src/MLSamplingLevelOptions.C
+++ b/src/stats/src/MLSamplingLevelOptions.C
@@ -28,6 +28,17 @@
 
 namespace QUESO {
 
+MLSamplingLevelOptions::MLSamplingLevelOptions()
+  :
+  m_env(NULL)
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  , m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+{
+  this->set_defaults();
+  this->set_prefix("");
+}
+
 MLSamplingLevelOptions::MLSamplingLevelOptions(
   const BaseEnvironment& env,
   const char*                   prefix)
diff --git a/src/stats/src/MLSamplingOptions.C b/src/stats/src/MLSamplingOptions.C
index 484a1ee42..7c58b66e9 100644
--- a/src/stats/src/MLSamplingOptions.C
+++ b/src/stats/src/MLSamplingOptions.C
@@ -28,6 +28,17 @@
 
 namespace QUESO {
 
+MLSamplingOptions::MLSamplingOptions()
+  :
+  m_env(NULL)
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  , m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+{
+  this->set_defaults();
+  this->set_prefix("");
+}
+
 MLSamplingOptions::
 MLSamplingOptions(const BaseEnvironment& env, const char* prefix)
 {
diff --git a/src/stats/src/MetropolisHastingsSGOptions.C b/src/stats/src/MetropolisHastingsSGOptions.C
index ac683fa97..13f59042a 100644
--- a/src/stats/src/MetropolisHastingsSGOptions.C
+++ b/src/stats/src/MetropolisHastingsSGOptions.C
@@ -50,6 +50,9 @@ MhOptionsValues::MhOptionsValues(
   )
   :
   m_env(NULL)
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  , m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
   if (alternativeRawSsOptionsValues     ) m_alternativeRawSsOptionsValues      = *alternativeRawSsOptionsValues;
diff --git a/src/stats/src/MonteCarloSGOptions.C b/src/stats/src/MonteCarloSGOptions.C
index da813bd75..362cca90c 100644
--- a/src/stats/src/MonteCarloSGOptions.C
+++ b/src/stats/src/MonteCarloSGOptions.C
@@ -48,6 +48,9 @@ McOptionsValues::McOptionsValues(
   const SsOptionsValues* alternativeQSsOptionsValues
 #endif
   )
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  : m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
   if (alternativePSsOptionsValues) m_alternativePSsOptionsValues = *alternativePSsOptionsValues;
diff --git a/src/stats/src/StatisticalForwardProblemOptions.C b/src/stats/src/StatisticalForwardProblemOptions.C
index 7d71c134e..5aed35fdd 100644
--- a/src/stats/src/StatisticalForwardProblemOptions.C
+++ b/src/stats/src/StatisticalForwardProblemOptions.C
@@ -43,6 +43,9 @@ namespace QUESO {
 
 // Default constructor -----------------------------
 SfpOptionsValues::SfpOptionsValues()
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  : m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
   this->set_defaults();
   this->set_prefix("");
diff --git a/src/stats/src/StatisticalInverseProblemOptions.C b/src/stats/src/StatisticalInverseProblemOptions.C
index 8998ee47d..418f26dcc 100644
--- a/src/stats/src/StatisticalInverseProblemOptions.C
+++ b/src/stats/src/StatisticalInverseProblemOptions.C
@@ -43,6 +43,9 @@ namespace QUESO {
 
 // Default constructor -----------------------------
 SipOptionsValues::SipOptionsValues()
+#ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
+  : m_parser(new BoostInputOptionsParser())
+#endif  // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
 {
   this->set_defaults();
   this->set_prefix("");