changed treatment of --version arg; remember to print it in Configuration like -...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 22 Jan 2015 14:00:12 +0000 (15:00 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 22 Jan 2015 14:00:12 +0000 (15:00 +0100)
src/config/configuration.cpp
src/config/configuration.h
src/config/option/versionoption.cpp

index 2bc85b0..0a17909 100644 (file)
@@ -63,6 +63,7 @@ Configuration::Configuration() :
     ResolvedIpTtlThreshold( 10 ),
     Hosts(),
     RatioRandomHosts( 1.0f ),
+    PrintVersion( false ),
     RandomNumberGenerator( boost::numeric_cast<unsigned int>(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)
index ebce5c2..bf8e396 100644 (file)
@@ -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;
 };
 
index 4828e89..6d058e5 100644 (file)
@@ -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;
 }