#ifndef _AP_VALIDATOR_INCLUDE_H_
#define _AP_VALIDATOR_INCLUDE_H_

/*define TEST when dubuging and testing */
#define TEST

#include <iostream>
#include <vector>
#include <string>
using std::vector;
using std::string;

/*BOINC LIB*/
#include "config.h"
#include "boinc_db.h"
#include "sched_msgs.h"
#include "sched_config.h"
#include "sched_util.h"
#include "util.h"
#include "track_mem.h"

/* don't consider mismatches between pulses of power below
 * threshold*THRESHOLD_FUDGE as errors.*/
static const float THRESHOLD_FUDGE = 1.01;

/* FLOTING POINT TOLERANCE VALUE DEFINITION */
static const float TOLERANCE_PEAK_POWER = 0.001;  // Tolerance for variations in returned power
static const float TOLERANCE_PERIOD = 1e-4; 	// Tolerance for variations in period
static const float TOLERANCE_TIME = 1.0 / 86400.0;  // 1 second as a fraction of a day

/* AstroPulse ErrorHandle Class */
class ErrorHandle {
  std::string kind;
  std::string s;
public:
	ErrorHandle(const char* kind0, string const & s0)
		: kind(kind0), s(s0)
	{

	};
	ErrorHandle(const ErrorHandle &h) : kind(h.kind), s(h.s) {};

	std::string what() const
	{
		return kind + s;
	};
};

class ResultFileError : public track_mem<ResultFileError>, public ErrorHandle {
public:
	ResultFileError(std::string const & s0)
		: track_mem<ResultFileError>("ResultFileError"),
		  ErrorHandle("Invalid ResultFile : ", s0)
	{
	}
	ResultFileError(const ResultFileError &h) :
	  track_mem<ResultFileError>("ResultFileError (copy)"), ErrorHandle(h) {};
};

class ValidatorError : public track_mem<ValidatorError>,public ErrorHandle {
public:
	ValidatorError(std::string const & s0)
		: track_mem<ValidatorError>("ValidatorError"),
		  ErrorHandle("Invalid in Validator : ", s0)
	{
	};
	ValidatorError(const ValidatorError &h) :
	  track_mem<ValidatorError>("ValidatorError (copy)"), ErrorHandle(h) {};
};


#endif
