///////////////////////////////////////////////////////////
// File:			pg_timeseries.h
//
// Author:			Stefan Liersch
// Contact:			stefan.liersch@googlemail.com,
//					stefan.liersch@ufz.de
//
// Date:			2007-08-13
// last modified:	2007-08-13
//
//---------------------------------------------------------
// DESCRIPTION
//---------------------------------------------------------
// This class represents a time series table containing
// a date and a value column.
// Functions to load the time series from a PostgreSQL database
// are provided her
//
//---------------------------------------------------------
// ToDo
//---------------------------------------------------------
// 
//
///////////////////////////////////////////////////////////

//---------------------------------------------------------
#ifndef __PG_TIMESERIES_H__
#define __PG_TIMESERIES_H__
//---------------------------------------------------------

#include "wx/datetime.h"
#include "wx/arrstr.h"

#include "pgsql/pgdatabase.h"
//---------------------------------------------------------

class CTimeSeries
{
public:
	CTimeSeries(void);
	CTimeSeries(const char* tablename,
				const char* date_col, const char* value_col,
				double NoData,
				wxDateTime begin, wxDateTime end);

	~CTimeSeries(void);

	wxString			Get_Name()			{return(m_name);}
	wxString			Get_date_col()		{return(m_date_col);}
	wxString			Get_value_col()		{return(m_value_col);}
	double				Get_data(int i)		{ return(i<m_nValues ? m_pData[i] : -9999); }
	int					Get_nValues()		{return(m_nValues);}
	//int					Get_nValues()		{return(_Set_nDays_Period());}
	double				Get_NoData()		{return(m_NoData); }
	bool				Get_HasNoData()		{return(m_b_hasNoData);}
	wxDateTime			Get_Date_Begin()	{return(m_begin);}
	wxDateTime			Get_Date_End()		{return(m_end);}
	int					Get_weight()		{return(m_weight);}

	void				Set_Name(const char* tablename);
	void				Set_Name(wxString tablename);
	void				Set_DateCol(const char* date_col);
	void				Set_DateCol(wxString date_col);
	void				Set_ValueCol(const char* value_col);
	void				Set_ValueCol(wxString value_col);
	void				Set_Data(int i, double value);
	bool				Set_nValues(wxDateTime begin, wxDateTime end);
	bool				Set_Date_Begin(wxDateTime begin);
	bool				Set_Date_End(wxDateTime end);
	void				Set_nValues(int nval);
	bool				Set_Create_m_pData(int nval);
	void				Set_Weight(int weight);

private:
	wxString			m_name;				// name of time series table in database
	wxString			m_date_col;			// name of the column storing the date
	wxString			m_value_col;		// name of the column storing the data
	double*				m_pData;			// pointer of daily time series data
	int					m_nValues;			// number of values (days) in time series
	double				m_NoData;			// NoData value
	bool				m_b_hasNoData;		// true, if time series contains NoData values
	wxDateTime			m_begin;			// first day of time series
	wxDateTime			m_end;				// last day of time series
	int					m_weight;			// weighting factor of time series in the context
											// with other time series

	int					_Set_nValues();		// set number of values (usually days)
											// using begin and end date
};
//---------------------------------------------------------

#endif /*__PG_TIMESERIES_H__*/