Split the parse_configuration_options
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 8 Oct 2011 18:23:50 +0000 (15:23 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 8 Oct 2011 18:23:50 +0000 (15:23 -0300)
- The hosts are parsed in their own method

src/config/configurationoptions.cpp
src/config/configurationoptions.h

index 5947d68..449b7c5 100644 (file)
@@ -179,6 +179,8 @@ bool ConfigurationOptions::parse_generic_options(
         Configuration *configuration
 )
 {
+    BOOST_ASSERT(configuration != NULL);
+
     // help
     if ( vm.count( HelpCmdStr ) > 0 )
     {
@@ -221,6 +223,8 @@ bool ConfigurationOptions::parse_configuration_options(
         Configuration *configuration
 )
 {
+    BOOST_ASSERT(configuration != NULL);
+
     BOOST_FOREACH( ConfigurationOptionItem configuration_option, ConfigOptions )
     {
         bool validated = configuration_option->validate( vm );
@@ -230,6 +234,27 @@ bool ConfigurationOptions::parse_configuration_options(
         }
     }
 
+    bool hosts_parsed = parse_hosts_options(vm, configuration);
+
+    return hosts_parsed;
+}
+
+/**
+ * @brief Parse the hosts section options.
+ *
+ * @param vm The input @c boost::program_options::variables_map.
+ * @param configuration The output @c Configuration filled with the parsed
+ * hosts options.
+ *
+ * @return @c true if the hosts were parsed correctly, or @c false otherwise.
+ */
+bool ConfigurationOptions::parse_hosts_options(
+        const variables_map &vm,
+        Configuration *configuration
+)
+{
+    BOOST_ASSERT(configuration != NULL);
+
     size_t host_down_limit_count = static_cast<size_t>( configuration->get_hosts_down_limit() );
 
     BOOST_FOREACH( HostConfigurationOptionItem host_option, HostOptions )
index 20cd660..a4ffccb 100644 (file)
@@ -59,6 +59,12 @@ public:
     ) const;
 
 private:
+    bool parse_hosts_options(
+            const boost::program_options::variables_map &vm,
+            Configuration *configuration
+    );
+
+private:
     ConfigurationOptionList GenericOptions;
     ConfigurationOptionList ConfigOptions;
     HostConfigurationOptionList HostOptions;