Host.h

Go to the documentation of this file.
00001 
00014 // Host.h -- interface for the Host class
00015 
00016 #ifndef HOST_H_
00017 #define HOST_H_
00018 
00019 #ifdef _MSC_VER
00020 #pragma once
00021 #endif // MSVC
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 // IpAddress class
00027 #include "IpAddress.h"
00028 
00029 
00031 // Host
00032 
00033 // Represents a device on a TCP/IP network that can be identified
00034 // by a logical IP address
00035 
00036 class Host
00037 {
00038 public:
00039     // Constructors.
00040         Host();
00041     Host( const std::string& name );
00042     Host( const IpAddress& address );
00043     Host( const hostent& host );
00044     Host( const Host& host );
00045 
00046     // Assignment and comparison operators
00047     Host& operator=( const Host& host );
00048     bool operator==( const Host& host ) const;
00049     bool operator<( const Host& host ) const;
00050 
00051     // Contains the DNS name of the host
00052         std::string getName() const;
00053 
00054     // Provides an collection of other DNS names that resolve to the Host
00055     const std::vector<std::string>& getAliases() const;
00056 
00057     // retrieve collection of IP addresses.
00058     const std::vector<IpAddress>& getIpAddresses() const;
00059 
00060     // Verification 
00061     bool isDefined() const;
00062 
00063     // Retrive the host for the local machine
00064     static const Host& getLocalhost();
00065 
00066     // Standard c++ iostream insertor
00067         std::ostream& operator<<( std::ostream& stream) const;
00068 
00069 protected:
00070         // Overridable variable manipulation
00071         void set( const std::string& name );
00072         void set( const IpAddress& name );
00073         void set( const hostent& host );
00074 
00075     // Retrieving hostent from the given address entry, return success/failure
00076     static bool find(const std::string& name,struct hostent* data) throw();
00077         static bool find(const IpAddress& address,struct hostent* data) throw();
00078 
00079 private:
00080         std::string hostName;
00081     std::vector< std::string > ipAliases;
00082     std::vector< IpAddress > ipAddresses;
00083     static std::auto_ptr<Host> ipLocalhost;
00084 };
00085 
00086 
00087 #endif // HOST_H_

Generated on Tue Mar 28 09:10:14 2006 for Simple SOAP by  doxygen 1.4.6