/*******************************************************************************
 * Copyright (c) 2015-2016 ONERA.
 * Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
 * Tous droits réservés.
 *
 * Ce programme et les éléments qui l'accompagnent sont mis à disposition
 * aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
 * au droit français et respectant les principes de diffusion des logiciels libres.
 * Vous pouvez utiliser, modifier et/ou redistribuer ce programme
 * sous les conditions de la licence CeCILL-C (http://www.cecill.info).

 * This software is property of ONERA (the French Aerospace Lab).
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under
 * the terms of the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software.
 * You can  use, modify and/ or redistribute the software under the terms of
 * the CeCILL-C license (http://www.cecill.info).
 *
 * Contributeurs/contributors:
 *     Florent Teichteil-Königsbuch (ONERA - Centre de Toulouse) - initial API and implementation
 *
 *******************************************************************************/


#ifndef EPOCH_CONSOLE_ALTARICA_HH
#define EPOCH_CONSOLE_ALTARICA_HH

//#include "grammars/altarica/altarica_driver.hh"
//#include "grammars/altarica/AltaricaState.hh"
#include "grammars/altarica/AltaricaGenerator.hh"
#include "grammars/altarica/expressions/Expressions.hh"


#include "console/ParsingDriverConsoleReporter.hh"

#include <iostream>
#include <string>

namespace epoch {
	namespace console {
		typedef std::auto_ptr<epoch::altarica::Expression> MyExpressionPtr;

		/*struct AltaricaLogic {
			const epoch::altarica::Node& m_rMainNode;
			MyExpressionPtr m_pExpression;
			std::auto_ptr<epoch::altarica::OpenValue> m_pConstantTrue;

			AltaricaLogic(const epoch::altarica::Node& n, MyExpressionPtr e);

			bool holds(const epoch::altarica::AltaricaGenerator::State& s) const;
		};

		AltaricaLogic::AltaricaLogic(const epoch::altarica::Node& n, MyExpressionPtr e)
		: m_rMainNode(n), m_pExpression(e) {
			m_pConstantTrue = std::auto_ptr<epoch::altarica::OpenValue>(new epoch::altarica::OpenBool(true, false));
		}

		bool AltaricaLogic::holds(const epoch::altarica::AltaricaGenerator::State& s) const {
			epoch::altarica::OpenValue* v = m_pExpression->evaluate(s.as_, &m_rMainNode);
			bool r = v->equals(m_pConstantTrue.get());
			delete v;
			return r;
		}*/

		// template <class T>
		// bool from_string(T& t,
		// 				 const std::string& s,
		// 				 std::ios_base& (*f)(std::ios_base&))
		// {
		//   std::istringstream iss(s);
		//   return !(iss >> f >> t).fail();
		// }

		void printStates(int ps, int maxDepth, epoch::altarica::AltaricaState* s, epoch::altarica::AltaricaModel* m);

		// struct AltaricaLogic {
		// 	virtual ~AltaricaLogic() {}
		// 	virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const =0;
		// };

		// struct AltaricaLogicF1 : public AltaricaLogic {
		// 	virtual ~AltaricaLogicF1() {}
		// 	inline virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const {return true;}
		// };

		// struct AltaricaLogicF2 : public AltaricaLogic {
		// 	epoch::altarica::AltaricaModel* m_pModel;
		// 	std::auto_ptr<epoch::altarica::Value> m_pConstant;
		// 	std::string varName;
		// 	bool invert;

		// 	virtual ~AltaricaLogicF2() {}

		// 	AltaricaLogicF2(epoch::altarica::AltaricaModel* model, std::string vn, std::string value, bool invert_comp);

		// 	virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const;
		// };

		bool DoAltarica(const std::string& modelFile, const std::string& initFile, const std::string& var1, const std::string& value1, const std::string& var2, const std::string& value2, bool ds, int ps, bool invert_comp1, bool invert_comp2, 
		                int ac, char* av[], int algo, int hess, int blas, double threshold, unsigned int dtimebound, double ctimebound, bool printfunction, const std::string& printGraph);
	} // namespace console
} // namespace epoch

#endif // EPOCH_CONSOLE_ALTARICA_HH
