2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
28 #include <boost/function.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/utility.hpp>
31 #include <boost/asio/io_service.hpp>
32 #include <boost/asio/ip/address.hpp>
33 #include <boost/weak_ptr.hpp>
35 #include "host/pingstatus.h"
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 typedef boost::shared_ptr<boost::asio::io_service> IoServiceItem;
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
48 * @brief Abstract class for pingers.
49 * Scope: one object per host.
51 * Holds a weak_ptr to itself, so can create shared_ptrs from self
52 * (adapted from amime project)
54 class Pinger : boost::noncopyable
57 typedef boost::weak_ptr<Pinger> WeakPtr;
60 const boost::asio::ip::address &ip,
61 const uint16_t destination_port,
62 boost::function<void(PingStatus,long)> ping_done_callback
65 virtual void stop_pinging() = 0;
71 Pinger::WeakPtr get_myself() const;
72 virtual void set_myself(const Pinger::WeakPtr &myself);
75 Pinger::WeakPtr Myself;
79 //-----------------------------------------------------------------------------
81 //-----------------------------------------------------------------------------
83 typedef boost::shared_ptr<Pinger> PingerItem;