/***************************************************************************
*   Copyright (C) 2006 by Ian Reinhart Geiser   *
*   geiseri@sourcextreme.com   *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU Library General Public License as       *
*   published by the Free Software Foundation; either version 2 of the    *
*   License, or (at your option) any later version.                       *
*                                                                         *
*   This program 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 Library General Public     *
*   License along with this program; if not, write to the                 *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
#ifndef KRPCNODEINTERFACE_H
#define KRPCNODEINTERFACE_H

#include <qglobal.h>
// #include "nodereference.h"

class QHostAddress;

namespace KRPC
{
	class NodeID;

	/**
	This is the interface for Nodes that can be kept in the distributed hash table.

		@author Ian Reinhart Geiser <geiseri@kde.org>
	*/
	class NodeInterface
	{
	public:
		NodeInterface(const QHostAddress &host, unsigned int port )
		{
			Q_UNUSED(host);
			Q_UNUSED(port);
		}
		virtual ~NodeInterface() {};

		/**
		 * Return the address of the host node.
		 */
		virtual QHostAddress address() const = 0;
		/**
		 * Return the port the address is listening on.
		 */
		virtual unsigned int port() const = 0;
		/**
		 * Return the unique key for the node.
		 */
		virtual NodeID key() const = 0;

		/**
		 * Generic node operation.
		 */
		virtual NodeInterface *predecessor() const = 0;
		/**
		 * Generic node operation.
		 */
		virtual NodeInterface *successor() const = 0;
		/**
		 * Generic node operation.
		 */
		virtual NodeInterface *upper() const = 0;
		/**
		 * Generic node operation.
		 */
		virtual NodeInterface *lower() const = 0;
		/**
		 * Generic node operation.
		 */
		virtual void join( NodeInterface *parent ) = 0;
		/**
		 * Generic node operation.
		 */
		virtual NodeInterface *find( const NodeID &key) const = 0;

		virtual NodeID previousKey() const = 0;
		virtual NodeID nextKey() const = 0;
		virtual NodeID upperKey() const = 0;
		virtual NodeID lowerKey() const = 0;
		virtual bool hasKey( const NodeID &key ) const = 0;
		virtual void put( const NodeID &key, NodeInterface *node ) = 0;
		virtual NodeInterface *get( const NodeID &key ) const = 0;
	};

}

#endif

