/***********************************************************************
**
**   windmeasurementlist.h
**
**   This file is part of Cumulus.
**
************************************************************************
**
**   Copyright (c):  2002 by André Somers
**
**   This file is distributed under the terms of the General Public
**   Licence. See the file COPYING for more information.
**
**   $Id: windmeasurementlist.h,v 1.2 2004/02/24 10:51:46 andre Exp $
**
***********************************************************************/

#ifndef WINDMEASUREMENTLIST_H
#define WINDMEASUREMENTLIST_H

#include <qdatetime.h>

#include "limitedlist.h"
#include "altitude.h"
#include "vector.h"

/**The WindMeasurementList is a list that can contain and process windmeasurements.
  *@author André Somers
  */
struct WindMeasurement {
  Vector vector;
  int quality;
  QTime time;
  Altitude altitude;
};
  
class WindMeasurementList : protected LimitedList<WindMeasurement>  {
public: 
	WindMeasurementList();
	~WindMeasurementList();

  /**
   * Returns the weighted mean windvector over the stored values, or 0
   * if no valid vector could be calculated (for instance: too little or
   * too low quality data).
   */
  Vector getWind(Altitude alt);
  /** Adds the windvector vector with quality quality to the list. */
  void addMeasurement(Vector vector, Altitude alt, int quality);

protected:
  /**
   * getLeastImportantItem is called to identify the item that should be
   * removed if the list is too full. Reimplemented from LimitedList.
   */
  virtual uint getLeastImportantItem();

  /**
   * Compares two measurements by altitude.
   */
  int compareItems(QCollection::Item s1, QCollection::Item s2);

};

#endif
