/*********************************************************************
 * This file is part of the PRAPI library.
 *
 * Copyright (C) 2001 Topi Mäenpää
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision: 1.4 $
 *********************************************************************/

#ifndef _CLUSTER_H
#define _CLUSTER_H

#include <List.h>
#include <string>
#include "Sample.h"

namespace prapi
{
	/**
	 * Cluster is a sample list with an additional sample as a cluster
	 * representative as used by the clustering algorithms.
	 **/
	template <class T, class I=std::string, class C=int> class Cluster : public util::List<Sample<T,I,C> >
	{
	public:
		/**
		 * Create an empty cluster.
		 **/
		Cluster() {}
		/**
		 * Copy a cluster.
		 **/
		Cluster(const Cluster& other) : util::List<Sample<T,I,C> >(other), _representativeSample(other._representativeSample) {}

		/**
		 * Copy a cluster.
		 **/
		Cluster& operator=(const Cluster& other);

		/**
		 * Get a copy of the current cluster representative.
		 **/
		Sample<T,I,C> getRepresentative(void) const { return _representativeSample; }
		/**
		 * Get the current cluster representative.
		 **/
		Sample<T,I,C>& representative(void) { return _representativeSample; }
		/**
		 * Set the cluster representative.
		 **/
		void setRepresentative(const Sample<T,I,C>& smpl) const { _representativeSample = smpl; }
		
	protected:
		Sample<T,I,C> _representativeSample;
	};

	template <class T, class I, class C> Cluster<T,I,C>& Cluster<T,I,C>::operator= (const Cluster<T,I,C>& other)
	{
		util::List<Sample<T,I,C> >::operator=(other);
		_representatiteSample = other._representativeSample;
		return *this;
	}
}

#endif
