
#ifndef SIGNAL_H
#define SIGNAL_H

#include <vector>
#include <string>
#include <cmath>
#include <stdlib.h>
#include <ctime>
#include "my_point.h"
#include "fft.h"

// See implementation of operator+
#define MAX_DEC_DIGITS 10

typedef unsigned long ul;
typedef unsigned int uint;

class Signal{

	private:
		string sourceFile;
		vector<Point> points;
		
		//Used for drawing
		double minXdist;
		double minYdist;
		
// Statistics-----------------
		double maxY;
		double maxX;
		double minY;
		double minX;
		double mean;				// Mesos Oros
		double variance;			// Diakimansi
		double dispersion;			// Diaspora
		double stdDeviation;		// Typiki apoklisi
		double avgDeviation;		// Mesi apoklisi
		double skewness;			// Loxotita
		double kurtosis;			// Kurtwsh
// ----------------------------
		
		
		// Methods
		
	private:
		void calcMinMaxMean();
		void calcVariance();
		void calcDispersion();
		void calcStdDeviation();
		void calcAvgDeviation();
		void calcSkewness();
		void calcKurtosis();
		void calcStats();
		
		ul sizeToPowOfTow(ul size);

	public:
		Signal();
		Signal(const char * fname);
		Signal(const Signal & sig);
		Signal(vector<Point> pts);
		~Signal();
		
		void load(const char * fname);
		void save(const char * fname);
		ul size();
		bool isEmpty();
		string toString() const;
		
		// Get
		string getFileName();
		double getMinXdist();
		double getMinYdist();
		double getMaxY();
		double getMaxX();
		double getMinY();
		double getMinX();
		double getMean();
		double getVariance();
		double getDispersion();
		double getStdDeviation();
		double getAvgDeviation();
		double getSkewness();
		double getKurtosis();

		void moveHor(double pts);
		void moveVer(double pts);
		void addNoise(double max);

		Signal getSampledBy(int step);
		Signal getQuantedWith(int levels);

		Point & operator[](ul index);
		friend ofstream & operator<<(ofstream & out, const Signal &sig);
		friend ifstream & operator>>(ifstream & in, Signal &sig);
		friend ostream & operator<<(ostream & out, const Signal &sig);
		Signal& operator+=(const Point&);
		Signal operator+(const Signal&);
		Signal operator*(const Signal&);
		
		Signal convolution(const Signal&);
		void fft(Signal &real, Signal &imag, Signal &power);

};


#endif
