From: Christian Herdtweck Date: Thu, 22 Jan 2015 14:00:12 +0000 (+0100) Subject: changed treatment of --version arg; remember to print it in Configuration like -... X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=bfec40a6ccae093a58f5a14850b3f72a68067c2a;p=pingcheck changed treatment of --version arg; remember to print it in Configuration like --daemon option --- diff --git a/src/config/configuration.cpp b/src/config/configuration.cpp index 2bc85b0..0a17909 100644 --- a/src/config/configuration.cpp +++ b/src/config/configuration.cpp @@ -63,6 +63,7 @@ Configuration::Configuration() : ResolvedIpTtlThreshold( 10 ), Hosts(), RatioRandomHosts( 1.0f ), + PrintVersion( false ), RandomNumberGenerator( boost::numeric_cast(time(0)) ) { } @@ -241,7 +242,7 @@ float Configuration::get_ratio_random_hosts() const void Configuration::set_ratio_random_hosts( const float ratio ) { BOOST_ASSERT( (ratio > 0.0f) && (ratio <= 1.0f) ); - this->RatioRandomHosts = ratio; + RatioRandomHosts = ratio; } HostList Configuration::get_hosts() const @@ -251,7 +252,17 @@ HostList Configuration::get_hosts() const void Configuration::set_hosts( const HostList &hosts_list ) { - this->Hosts = hosts_list; + Hosts = hosts_list; +} + +bool Configuration::get_print_version() +{ + return PrintVersion; +} + +void Configuration::set_print_version( const bool do_print ) +{ + PrintVersion = do_print; } int Configuration::get_random_number(const int lowest, const int highest) diff --git a/src/config/configuration.h b/src/config/configuration.h index ebce5c2..bf8e396 100644 --- a/src/config/configuration.h +++ b/src/config/configuration.h @@ -103,6 +103,9 @@ public: int get_random_number(const int lowest, const int highest); + void set_print_version( const bool do_print ); + bool get_print_version(); + bool randomize_hosts(); private: @@ -128,6 +131,7 @@ private: int ResolvedIpTtlThreshold; HostList Hosts; float RatioRandomHosts; + bool PrintVersion; rand_gen_type RandomNumberGenerator; }; diff --git a/src/config/option/versionoption.cpp b/src/config/option/versionoption.cpp index 4828e89..6d058e5 100644 --- a/src/config/option/versionoption.cpp +++ b/src/config/option/versionoption.cpp @@ -49,16 +49,13 @@ VersionOption::~VersionOption() bool VersionOption::parse( const variables_map& vm, - Configuration * + Configuration *configuration ) { // version - if ( 1 <= vm.count( get_command_string() ) ) - { - // TODO GlobalOutput::print( version ) - cout << PROJECT_NAME << " version " << VERSION_STRING << endl; - return true; - } + bool print_version = ( 1<= vm.count( get_command_string() ) ); + configuration->set_print_version( print_version ); + GlobalLogger.info() << get_command_string() << "=" << print_version << endl; return false; }