From d46b599bf1821eb81121b834d0545ba48515ebe5 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 25 Feb 2012 15:15:02 -0200 Subject: [PATCH] Factory method to create the Pinger object that handles a list of protocols. --- src/host/pingerfactory.cpp | 24 ++++++++++++++++++++++++ src/host/pingerfactory.h | 6 ++++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/src/host/pingerfactory.cpp b/src/host/pingerfactory.cpp index 1d1a0e2..c8c17c8 100644 --- a/src/host/pingerfactory.cpp +++ b/src/host/pingerfactory.cpp @@ -27,6 +27,7 @@ #include #include +#include "host/pingrotate.h" #include "icmp/icmppinger.h" #include "tcp/tcppinger.h" @@ -111,3 +112,26 @@ PingerItem PingerFactory::createPinger( return PingerItem(); //lint !e527 } + +/** + * @brief Create a Pinger object suitable to the given list of protocols. + * + * @param protocol_list A list of the available ping protocols. + * @param io_serv The @c io_service object. + * @param network_interface The network interface name from where the ping + * packet will be sent. + * @return a Pinger object to able to ping using the given list of protocols. + */ +PingerItem PingerFactory::createPinger( + const PingProtocolList &protocol_list, + io_service &io_serv, + const string &network_interface +) +{ + BOOST_ASSERT( 0 < protocol_list.size() ); + BOOST_ASSERT( !network_interface.empty() ); + + return PingerItem( + new PingRotate( io_serv, network_interface, protocol_list ) + ); +} diff --git a/src/host/pingerfactory.h b/src/host/pingerfactory.h index 4e21b88..234e541 100644 --- a/src/host/pingerfactory.h +++ b/src/host/pingerfactory.h @@ -42,6 +42,12 @@ public: const std::string &network_interface ); + static PingerItem createPinger( + const PingProtocolList &protocol_list, + boost::asio::io_service &io_serv, + const std::string &network_interface + ); + private: PingerFactory(); ~PingerFactory(); -- 1.7.1