From 77a7ddf9c46f2d2a8b55ceb398bc7765b63872b5 Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Thu, 10 Mar 2011 15:34:25 +0100 Subject: [PATCH] Moved Host class from ping directory to config directory, because it is a configuration item --- src/CMakeLists.txt | 2 +- src/config/host.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/config/host.h | 45 +++++++++++++++++++++++++++++++++ src/ping/host.cpp | 66 ------------------------------------------------- src/ping/host.h | 45 --------------------------------- 5 files changed, 114 insertions(+), 112 deletions(-) create mode 100644 src/config/host.cpp create mode 100644 src/config/host.h delete mode 100644 src/ping/host.cpp delete mode 100644 src/ping/host.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74e9cc9..287be48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,11 +10,11 @@ include_directories( set( SOURCES config/configuration.cpp config/configurationreader.cpp + config/host.cpp icmp/icmpheader.cpp icmp/icmppacket.cpp icmp/ipv4header.cpp ping/boostpinger.cpp - ping/host.cpp ping/pinger.cpp ping/pingscheduler.cpp main.cpp diff --git a/src/config/host.cpp b/src/config/host.cpp new file mode 100644 index 0000000..4dd8e2c --- /dev/null +++ b/src/config/host.cpp @@ -0,0 +1,68 @@ +#include +#include + +#include "host.h" + +//----------------------------------------------------------------------------- +// Host +//----------------------------------------------------------------------------- + +Host::Host( std::string address ) : + Address( address ), + Port( 0 ), + Interval( 0 ), + Options() +{ +} + +Host::~Host() +{ +} + +std::string Host::get_address() const +{ + return Address; +} + +void Host::set_address( const std::string& address ) +{ + BOOST_ASSERT( !address.empty() ); + + this->Address = address; +} + +uint16_t Host::get_port() const +{ + return Port; +} + +void Host::set_port( const uint16_t port ) +{ + BOOST_ASSERT( ( 0 < port ) && ( port < std::numeric_limits::max() ) ); + + this->Port = port; +} + +uint Host::get_interval() const +{ + return Interval; +} + +void Host::set_interval( const uint interval ) +{ + BOOST_ASSERT( ( 0 < interval ) && ( interval < std::numeric_limits::max() ) ); + + this->Interval = interval; +} + +std::vector Host::get_options() const +{ + return Options; +} + +void Host::set_options( const std::vector &options ) +{ + BOOST_ASSERT( 0 < options.size() ); + + this->Options = options; +} diff --git a/src/config/host.h b/src/config/host.h new file mode 100644 index 0000000..3eb5534 --- /dev/null +++ b/src/config/host.h @@ -0,0 +1,45 @@ +#ifndef HOST_H +#define HOST_H + +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +// Host +//----------------------------------------------------------------------------- + +class Host +{ +public: + Host( std::string address ); + virtual ~Host(); + + std::string get_address() const; + void set_address( const std::string& address ); + + uint16_t get_port() const; + void set_port( const uint16_t port ); + + uint get_interval() const; + void set_interval( const uint interval ); + + std::vector get_options() const; + void set_options( const std::vector &options ); + +private: + std::string Address; + uint16_t Port; + uint Interval; + std::vector Options; + +}; + +//----------------------------------------------------------------------------- +// HostItem +//----------------------------------------------------------------------------- + +typedef boost::shared_ptr HostItem; + +#endif /* HOST_H */ diff --git a/src/ping/host.cpp b/src/ping/host.cpp deleted file mode 100644 index fff6da0..0000000 --- a/src/ping/host.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include - -#include "host.h" - -//----------------------------------------------------------------------------- -// Host -//----------------------------------------------------------------------------- - -Host::Host( std::string address ) : - Address( address ), - Port( 0 ), - Interval( 0 ), - Options() -{ -} - -Host::~Host() -{ -} - -std::string Host::get_address() const -{ - return Address; -} - -void Host::set_address( const std::string& address ) -{ - BOOST_ASSERT( !address.empty() ); - - this->Address = address; -} - -uint16_t Host::get_port() const -{ - return Port; -} - -void Host::set_port( const uint16_t port ) -{ - BOOST_ASSERT( ( 0 < port ) && ( port < std::numeric_limits::max() ) ); - - this->Port = port; -} - -uint Host::get_interval() const -{ - return Interval; -} - -void Host::set_interval( const uint interval ) -{ - BOOST_ASSERT( ( 0 < interval ) && ( interval < std::numeric_limits::max() ) ); - - this->Interval = interval; -} - -std::vector Host::get_options() const -{ - return Options; -} - -void Host::set_options( const std::vector &options ) -{ - this->Options = options; -} diff --git a/src/ping/host.h b/src/ping/host.h deleted file mode 100644 index 3eb5534..0000000 --- a/src/ping/host.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef HOST_H -#define HOST_H - -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// Host -//----------------------------------------------------------------------------- - -class Host -{ -public: - Host( std::string address ); - virtual ~Host(); - - std::string get_address() const; - void set_address( const std::string& address ); - - uint16_t get_port() const; - void set_port( const uint16_t port ); - - uint get_interval() const; - void set_interval( const uint interval ); - - std::vector get_options() const; - void set_options( const std::vector &options ); - -private: - std::string Address; - uint16_t Port; - uint Interval; - std::vector Options; - -}; - -//----------------------------------------------------------------------------- -// HostItem -//----------------------------------------------------------------------------- - -typedef boost::shared_ptr HostItem; - -#endif /* HOST_H */ -- 1.7.1