/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWREMOTE_HOSTCONNECTOR_H
#define __IWREMOTE_HOSTCONNECTOR_H

#include <iwremote/protocol.h>
#include <iwear/uid.h>
#include <string>
using std::string;

namespace iwear
{
    namespace net
    {

class ConnectionDescriptor;

enum RT {
rt_ipv4,
rt_ipv6,
rt_unix,
rt_other,
num_RT
};

/**
 * This holds the description of a host uid and the way how to connect to it
 */
struct HostConnector
{
   /**
    * the host uid
    */
    hostid_t host_id;

    string reachinfo;

    uint32_t reachme;
    
    uint32_t age;
    /**
     * estimated distance in hops
     */
    uint32_t est_hops;

    /**
     * This class is virtual and will contain everything necessary to connect
     * to the host
     */
    ConnectionDescriptor* condis;

    /**
     * This is set to true if the information about that host should never time out
     */
    bool authorative;

    HostConnector( const hostid_t& u, ConnectionDescriptor* c ) : host_id(u), 
					reachme(0), age(0), est_hops(0), condis(c), authorative(false) { }
    HostConnector( ) : reachme(0), age(0), est_hops(0), condis(0), authorative(false) { }

    bool operator<( const HostConnector& ) const;
};

inline bool HostConnector::operator<( const HostConnector& h ) const
{
    if( host_id < h.host_id ) return true;
    if( host_id > h.host_id ) return false;

    if( reachinfo < h.reachinfo ) return true;
    if( reachinfo > h.reachinfo ) return false;

    if( reachme < h.reachme ) return true;
    if( reachme > h.reachme ) return false;

//    if( condis < h.condis ) return true;
//    if( condis > h.condis ) return false;

    return false;
}

}
}
#endif
