From: Guilherme Maciel Ferreira Date: Sat, 8 Oct 2011 18:23:50 +0000 (-0300) Subject: Split the parse_configuration_options X-Git-Tag: v1.3~11^2~34^2~2 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=10af47fc5e25d76d93b10e387f121c1831368d17;p=pingcheck Split the parse_configuration_options - The hosts are parsed in their own method --- diff --git a/src/config/configurationoptions.cpp b/src/config/configurationoptions.cpp index 5947d68..449b7c5 100644 --- a/src/config/configurationoptions.cpp +++ b/src/config/configurationoptions.cpp @@ -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( configuration->get_hosts_down_limit() ); BOOST_FOREACH( HostConfigurationOptionItem host_option, HostOptions ) diff --git a/src/config/configurationoptions.h b/src/config/configurationoptions.h index 20cd660..a4ffccb 100644 --- a/src/config/configurationoptions.h +++ b/src/config/configurationoptions.h @@ -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;