Factory method to create the Pinger object that handles a list of protocols.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 25 Feb 2012 17:15:02 +0000 (15:15 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 25 Feb 2012 17:15:02 +0000 (15:15 -0200)
src/host/pingerfactory.cpp
src/host/pingerfactory.h

index 1d1a0e2..c8c17c8 100644 (file)
@@ -27,6 +27,7 @@
 #include <boost/asio/ip/tcp_raw_protocol.hpp>
 #include <boost/system/system_error.hpp>
 
+#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 )
+    );
+}
index 4e21b88..234e541 100644 (file)
@@ -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();