/*
 * port.h
 *
 * Copyright (c) 2002, 2003 Frerich Raabe <raabe@kde.org>
 *
 * 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. For licensing and distribution details, check the
 * accompanying file 'COPYING'.
 */
#ifndef PORT_H
#define PORT_H

#include <sys/types.h>

class QString;
class QStringList;
template <class T> class QValueList;

namespace Barry
{
	class Port;
	typedef QValueList<Port> PortList;

	class PortInterface
	{
		public:
			virtual ~PortInterface();
			virtual QString origin() const = 0;
			virtual QString name() const = 0;
			virtual QString version() const = 0;
			virtual QString installedVersion() const = 0;
			virtual QString directory() const = 0;
			virtual QString prefix() const = 0;
			virtual QString comment() const = 0;
			virtual QString description() const = 0;
			virtual QString maintainer() const = 0;
			virtual QStringList categories() const = 0;
			virtual PortList buildDeps() const = 0;
			virtual PortList runDeps() const = 0;
			virtual QString link() const = 0;
			virtual QStringList files() const = 0;
			virtual QStringList installedFiles() const = 0;
			virtual bool installed() const = 0;
			virtual long long size() const = 0;
	};

	class Port : public PortInterface
	{
		public:
			static void parsePkgName( const QString &pkgName,
                                      QString &name, QString &version );
			static Port fromPkgName( const QString &origin,
			                         const QString &pkgName );

			Port();
			Port( const Port &rhs );
			Port( const QString &origin );
			bool operator==( const Port &rhs ) const;
			bool operator!=( const Port &rhs ) const
			{ return !operator==( rhs ); }
			bool operator<( const Port &rhs ) const;
			bool operator<=( const Port &rhs ) const
			{ return operator<( rhs ) || operator==( rhs ); }
			bool operator>( const Port &rhs ) const
			{ return !operator<=( rhs ); }
			bool operator>=( const Port &rhs ) const
			{ return !operator<( rhs ); }
			Port &operator=( const Port &rhs );
			virtual ~Port();

			bool isNull() const { return d == 0; }

			virtual QString origin() const;
			virtual QString name() const;
			virtual QString version() const;
			virtual QString installedVersion() const;
			virtual QString directory() const;
			virtual QString prefix() const;
			virtual QString comment() const;
			virtual QString description() const;
			virtual QString maintainer() const;
			virtual QStringList categories() const;
			virtual PortList buildDeps() const;
			virtual PortList runDeps() const;
			virtual QString link() const;
			virtual QStringList files() const;
			virtual QStringList installedFiles() const;
			virtual bool installed() const;
			virtual long long size() const;

		private:
			Port( const QString &origin, const QString &name,
			      const QString &version );

			void determineAttributes() const;
			void initPort() const;

			struct Private;
			Private *d;
	};
};

#endif // PORT_H
// vim:ts=4:sw=4:noet:list
