From: Guilherme Maciel Ferreira Date: Mon, 2 May 2011 15:56:16 +0000 (+0200) Subject: Defining the type HostList as a vector of HostItem X-Git-Tag: v1.0~45 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=dbe36b1621e9db6101cbbaadb759d0b750a0e286;p=pingcheck Defining the type HostList as a vector of HostItem - provides a central point to change the container type - makes the code more readable - reduces the amount of code to read --- diff --git a/src/config/configuration.cpp b/src/config/configuration.cpp index b7f7c5e..353a73d 100644 --- a/src/config/configuration.cpp +++ b/src/config/configuration.cpp @@ -123,12 +123,12 @@ void Configuration::set_link_up_interval_in_min( const int link_up_interval_in_m LinkUpIntervalInMin = link_up_interval_in_min; } -vector< HostItem > Configuration::get_hosts() const +HostList Configuration::get_hosts() const { return Hosts; } -void Configuration::set_hosts( const vector< HostItem > &hosts_list ) +void Configuration::set_hosts( const HostList &hosts_list ) { this->Hosts = hosts_list; } diff --git a/src/config/configuration.h b/src/config/configuration.h index 4af5c32..b152aa2 100644 --- a/src/config/configuration.h +++ b/src/config/configuration.h @@ -6,6 +6,8 @@ #include #include +#include + #include "config/host.h" //----------------------------------------------------------------------------- @@ -44,8 +46,8 @@ public: int get_link_up_interval_in_min() const; void set_link_up_interval_in_min( const int link_up_interval_in_min ); - std::vector get_hosts() const; - void set_hosts( const std::vector &hosts_list ); + HostList get_hosts() const; + void set_hosts( const HostList &hosts_list ); private: bool Daemon; @@ -53,17 +55,23 @@ private: std::string SourceNetworkInterface; std::string NameServer; int HostsDownLimit; - const int MinHostsDownLimit; - const int MaxHostsDownLimit; + int MinHostsDownLimit; + int MaxHostsDownLimit; int PingFailLimit; - const int MinPingFailLimit; - const int MaxPingFailLimit; + int MinPingFailLimit; + int MaxPingFailLimit; std::string StatusNotifierCmd; int LinkUpIntervalInMin; - const int MinStableLinkIntervalInMin; - const int MaxStableLinkIntervalInMin; - std::vector Hosts; + int MinStableLinkIntervalInMin; + int MaxStableLinkIntervalInMin; + HostList Hosts; }; +//----------------------------------------------------------------------------- +// ConfigurationItem +//----------------------------------------------------------------------------- + +typedef boost::shared_ptr ConfigurationItem; + #endif /* CONFIGURATION_H */ diff --git a/src/config/configurationreader.cpp b/src/config/configurationreader.cpp index f4a7416..49d83b9 100644 --- a/src/config/configurationreader.cpp +++ b/src/config/configurationreader.cpp @@ -249,7 +249,7 @@ bool ConfigurationReader::parse_configuration_options( const variables_map &vm ) size_t hosts_names_count = 0; if ( vm.count( HostNameCmdStr ) > 0 ) { - vector hosts_list; + HostList hosts_list; vector hosts_names = vm[ HostNameCmdStr ].as< vector > (); BOOST_FOREACH( string host_name, hosts_names ) @@ -272,8 +272,8 @@ bool ConfigurationReader::parse_configuration_options( const variables_map &vm ) size_t hosts_interval_count = 0; if ( vm.count( HostIntervalCmdStr ) > 0 ) { - vector hosts_list = Config.get_hosts(); - vector::iterator hosts_it = hosts_list.begin(); + HostList hosts_list = Config.get_hosts(); + HostList::iterator hosts_it = hosts_list.begin(); vector hosts_intervals = vm[ HostIntervalCmdStr ].as< vector > (); BOOST_FOREACH( int host_interval_in_sec, hosts_intervals ) diff --git a/src/config/host.h b/src/config/host.h index c6f7ff7..02d292f 100644 --- a/src/config/host.h +++ b/src/config/host.h @@ -48,4 +48,10 @@ private: typedef boost::shared_ptr HostItem; +//----------------------------------------------------------------------------- +// HostList +//----------------------------------------------------------------------------- + +typedef std::vector< HostItem > HostList; + #endif /* HOST_H */