From: Guilherme Maciel Ferreira Date: Wed, 25 Jan 2012 23:11:58 +0000 (-0200) Subject: Renamed HostStatusAnalyzer to HostStatus. X-Git-Tag: v1.3~11^2~33 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6c14bbee444740fbf49d0aa8be1ef650aa335f49;p=pingcheck Renamed HostStatusAnalyzer to HostStatus. - This is a stronger noun name; - See "The Gravitational Pull of Functional Decomposition" at http://www.eetimes.com/design/embedded/4006522/Using-object-oriented-methods-to-achieve-C--s-promise-Part-3 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 706ed0d..b0fd7ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,7 +57,7 @@ set(SOURCES dns/dnsresolver.cpp dns/hostaddress.cpp dns/timetolive.cpp - host/hoststatusanalyzer.cpp + host/hoststatus.cpp host/messagepayload.cpp host/networkinterfacelist.cpp host/pinger.cpp diff --git a/src/host/hoststatusanalyzer.cpp b/src/host/hoststatus.cpp similarity index 80% rename from src/host/hoststatusanalyzer.cpp rename to src/host/hoststatus.cpp index 93a6229..dbe9e96 100644 --- a/src/host/hoststatusanalyzer.cpp +++ b/src/host/hoststatus.cpp @@ -17,7 +17,7 @@ in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ -#include "host/hoststatusanalyzer.h" +#include "host/hoststatus.h" #include @@ -27,16 +27,16 @@ using namespace std; using boost::shared_ptr; //----------------------------------------------------------------------------- -// HostStatusAnalyzer +// HostStatus //----------------------------------------------------------------------------- /** - * @param host_address the address of the host it has to analyze. - * @param ping_fail_percentage_limit the percentage threshold of pings that can + * @param host_address The address of the host it has to analyze. + * @param ping_fail_percentage_limit The percentage threshold of pings that can * fail. - * @param link_analyzer the object used to notify the status of the host. + * @param link_analyzer The object used to notify the status of the host. */ -HostStatusAnalyzer::HostStatusAnalyzer( +HostStatus::HostStatus( const string &host_address, const int ping_fail_limit_percentage, const shared_ptr link_analyzer @@ -53,14 +53,14 @@ HostStatusAnalyzer::HostStatusAnalyzer( BOOST_ASSERT( ( 0 <= PingFailLimitPercentage ) && ( PingFailLimitPercentage <= 100 ) ); } -HostStatusAnalyzer::~HostStatusAnalyzer() +HostStatus::~HostStatus() { } /** - * @param resolved_ip_count the number of IPs resolved for the host. + * @param resolved_ip_count The number of IPs resolved for the host. */ -void HostStatusAnalyzer::set_resolved_ip_count( const int resolved_ip_count ) +void HostStatus::set_resolved_ip_count( const int resolved_ip_count ) { BOOST_ASSERT( 1 <= resolved_ip_count ); @@ -71,7 +71,7 @@ void HostStatusAnalyzer::set_resolved_ip_count( const int resolved_ip_count ) * @return true if the amount of failed pings given to the host exceeded the * limit. */ -bool HostStatusAnalyzer::exceeded_ping_failed_limit() const +bool HostStatus::exceeded_ping_failed_limit() const { return ExceededPingFailedLimit; } @@ -80,7 +80,7 @@ bool HostStatusAnalyzer::exceeded_ping_failed_limit() const * Adds a ping status (success or failure). * @param ping_success */ -void HostStatusAnalyzer::update_ping_statistics( bool ping_success ) +void HostStatus::update_ping_statistics( bool ping_success ) { BOOST_ASSERT( 1 <= ResolvedIpCount ); BOOST_ASSERT( 0 <= PingsPerformedCount ); @@ -107,14 +107,14 @@ void HostStatusAnalyzer::update_ping_statistics( bool ping_success ) BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount ); } -bool HostStatusAnalyzer::tried_all_resolved_ip() const +bool HostStatus::tried_all_resolved_ip() const { BOOST_ASSERT( ( 0 < PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); return ( PingsPerformedCount == ResolvedIpCount ); } -void HostStatusAnalyzer::analyze_ping_statistics() +void HostStatus::analyze_ping_statistics() { BOOST_ASSERT( !HostAddress.empty() ); BOOST_ASSERT( PingsPerformedCount == ResolvedIpCount ); @@ -131,27 +131,27 @@ void HostStatusAnalyzer::analyze_ping_statistics() } -void HostStatusAnalyzer::reset_ping_counters() +void HostStatus::reset_ping_counters() { PingsPerformedCount = 0; PingsFailedCount = 0; } -void HostStatusAnalyzer::increase_ping_performed_count() +void HostStatus::increase_ping_performed_count() { ++PingsPerformedCount; BOOST_ASSERT( ( 0 <= PingsPerformedCount ) && ( PingsPerformedCount <= ResolvedIpCount ) ); } -void HostStatusAnalyzer::increase_ping_failed_count() +void HostStatus::increase_ping_failed_count() { ++PingsFailedCount; BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) ); } -void HostStatusAnalyzer::analyze_ping_failed_count() +void HostStatus::analyze_ping_failed_count() { BOOST_ASSERT( ( 0 <= PingFailLimitPercentage ) && ( PingFailLimitPercentage <= 100 ) ); BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) ); diff --git a/src/host/hoststatusanalyzer.h b/src/host/hoststatus.h similarity index 92% rename from src/host/hoststatusanalyzer.h rename to src/host/hoststatus.h index be115ca..491fc39 100644 --- a/src/host/hoststatusanalyzer.h +++ b/src/host/hoststatus.h @@ -17,8 +17,8 @@ in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ -#ifndef HOST_STATUS_ANALYZER_H -#define HOST_STATUS_ANALYZER_H +#ifndef HOST_STATUS_H +#define HOST_STATUS_H #include @@ -27,7 +27,7 @@ on this file might be covered by the GNU General Public License. #include "link/linkstatusanalyzer.h" //----------------------------------------------------------------------------- -// HostStatusAnalyzer +// HostStatus //----------------------------------------------------------------------------- /** @@ -35,15 +35,15 @@ on this file might be covered by the GNU General Public License. * responses (success or failure). And notifies its status. * Scope: one object per host. */ -class HostStatusAnalyzer +class HostStatus { public: - HostStatusAnalyzer( + HostStatus( const std::string &host_address, const int ping_fail_limit_percentage, const boost::shared_ptr link_analyzer ); - ~HostStatusAnalyzer(); + ~HostStatus(); void set_resolved_ip_count( const int resolved_ip_count ); bool exceeded_ping_failed_limit() const; @@ -76,4 +76,4 @@ private: }; -#endif // HOST_STATUS_ANALYZER_H +#endif // HOST_STATUS_H diff --git a/src/host/pingscheduler.h b/src/host/pingscheduler.h index fdc43ce..3f7f038 100644 --- a/src/host/pingscheduler.h +++ b/src/host/pingscheduler.h @@ -29,7 +29,7 @@ on this file might be covered by the GNU General Public License. #include "dns/dnsresolver.h" #include "link/linkstatusanalyzer.h" -#include "host/hoststatusanalyzer.h" +#include "host/hoststatus.h" #include "host/pinger.h" #include "host/pingerfactory.h" #include "host/pinginterval.h" @@ -98,7 +98,7 @@ private: /// The port to ping at destination host int DestinationPort; /// Object responsible to evaluate the status of the host - HostStatusAnalyzer HostAnalyzer; + HostStatus HostAnalyzer; /// Internal boost pinger object boost::shared_ptr Ping; /// Thread object diff --git a/test/CMakeLists.test_hoststatus.txt b/test/CMakeLists.test_hoststatus.txt new file mode 100644 index 0000000..2261a76 --- /dev/null +++ b/test/CMakeLists.test_hoststatus.txt @@ -0,0 +1,15 @@ +# compiler: creates the binaries +add_executable(test_hoststatus + test_hoststatus.cpp + ${CMAKE_SOURCE_DIR}/src/host/hoststatus.cpp +) + +# linker: link the program against the libraries +target_link_libraries( + test_hoststatus + ${I2NCOMMON_LIBRARIES} + ${Boost_LIBRARIES} +) + +# cmake: invocation via "make test" +add_test(test_hoststatus test_hoststatus) diff --git a/test/CMakeLists.test_hoststatusanalyzer.txt b/test/CMakeLists.test_hoststatusanalyzer.txt deleted file mode 100644 index 901dead..0000000 --- a/test/CMakeLists.test_hoststatusanalyzer.txt +++ /dev/null @@ -1,15 +0,0 @@ -# compiler: creates the binaries -add_executable(test_hoststatusanalyzer - test_hoststatusanalyzer.cpp - ${CMAKE_SOURCE_DIR}/src/host/hoststatusanalyzer.cpp -) - -# linker: link the program against the libraries -target_link_libraries( - test_hoststatusanalyzer - ${I2NCOMMON_LIBRARIES} - ${Boost_LIBRARIES} -) - -# cmake: invocation via "make test" -add_test(test_hoststatusanalyzer test_hoststatusanalyzer) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 131855c..975be0c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,7 +25,7 @@ enable_testing() # cmake: inclusion of each test case cmake file include(CMakeLists.test_messagepayload.txt) -include(CMakeLists.test_hoststatusanalyzer.txt) +include(CMakeLists.test_hoststatus.txt) include(CMakeLists.test_ipv4header.txt) include(CMakeLists.test_ipv6header.txt) include(CMakeLists.test_icmpv4header.txt) @@ -34,7 +34,7 @@ include(CMakeLists.test_icmpv6header.txt) # cmake: add a custom "make check" target which automatically builds the binary add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS test_messagepayload - test_hoststatusanalyzer + test_hoststatus test_ipv4header test_ipv6header test_icmpv4header diff --git a/test/test_hoststatusanalyzer.cpp b/test/test_hoststatus.cpp similarity index 93% rename from test/test_hoststatusanalyzer.cpp rename to test/test_hoststatus.cpp index 2e2d788..920c2dc 100644 --- a/test/test_hoststatusanalyzer.cpp +++ b/test/test_hoststatus.cpp @@ -28,9 +28,9 @@ on this file might be covered by the GNU General Public License. #include "mock_linkstatusanalyzer.h" -#include "host/hoststatusanalyzer.h" +#include "host/hoststatus.h" -BOOST_AUTO_TEST_SUITE( TestHostStatusAnalyzer ) +BOOST_AUTO_TEST_SUITE( TestHostStatus ) BOOST_AUTO_TEST_CASE( fail_percentage_10 ) { @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE( fail_percentage_10 ) int resolved_ip_count = 10; LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer ); - HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status ); + HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status ); host_status.set_resolved_ip_count( resolved_ip_count ); host_status.update_ping_statistics( true ); @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE( fail_percentage_50 ) int resolved_ip_count = 10; LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer ); - HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status ); + HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status ); host_status.set_resolved_ip_count( resolved_ip_count ); host_status.update_ping_statistics( true ); @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE( fail_percentage_80 ) int resolved_ip_count = 10; LinkStatusAnalyzerItem link_status( new LinkStatusAnalyzer ); - HostStatusAnalyzer host_status( "localhost", ping_fail_percentage_limit, link_status ); + HostStatus host_status( "localhost", ping_fail_percentage_limit, link_status ); host_status.set_resolved_ip_count( resolved_ip_count ); host_status.update_ping_statistics( false );