/**
 * @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_REMOTEDESCRIPTOR_H
#define __IWREMOTE_REMOTEDESCRIPTOR_H

#ifndef __IWREMOTE_PROTOCOL_H
#include <iwremote/protocol.h>
#endif
#include <iwear/uid.h>

#include <vector>
using std::vector;

namespace iwear
{
    namespace net
    {
class RemoteObject;
/**
 * This is a collection of data abstractly describing an object, on what host
 * it resides and what interfaces it implements. It has to be kept in sync with
 * the RPCSearch ObjectInformation class.
 */
struct RemoteDescriptor
{
    /**
     * The actual object that is to be described
     */
    oid_t object_id;

    /**
     * The host on which the object resides (how it can be found is described
     * at another place, the HostConnector)
     */
    hostid_t host_id;

    /**
     * A Short human readable description of the object
     */
    std::string name;

    uint32_t age;
/* this info should go inly in hostconnector
    string reachinfo;


    uint32_t est_hops;
*/
    /**
     * A single Object might be able to offer multiple class id intefaces (in case of inheritance)
     */
    vector<cid_t> class_ids;

    bool operator<( const RemoteDescriptor& ) const;

    RemoteDescriptor( ) : object_id(0,0), host_id(0,0), age(0) { }
    RemoteDescriptor( int ) : object_id(0,0), host_id(0,0), age(0) { }
    RemoteDescriptor( RemoteObject* );
};

inline bool RemoteDescriptor::operator<( const RemoteDescriptor& r ) const
{
    if( object_id < r.object_id ) return true;
    if( object_id > r.object_id ) return false;

    if( host_id < r.host_id ) return true;
    if( host_id > r.host_id ) return false;

    if( name < r.name ) return true;
    if( name > r.name ) return false;
/*
    if( reachinfo < r.reachinfo ) return true;
    if( reachinfo > r.reachinfo ) return false;
*/
    if( class_ids.size() < r.class_ids.size() ) return true;
    if( class_ids.size() > r.class_ids.size() ) return false;

    for( size_t i = 0; i < class_ids.size(); ++i )
    {
	if( class_ids[i] < r.class_ids[i] ) return true;
	if( class_ids[i] > r.class_ids[i] ) return false;
    }
    return false;
}

	
}
}
#endif
