/*******************************************************************************
 * Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
 * Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab) et de
 * l'IRT AESE (IRT Saint Exupéry).
 * 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) and of
 * the IRT AESE (IRT Saint Exupéry).
 * 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:
 *     Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
 *     Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
 *
 *******************************************************************************/

#ifndef ALTA_VALUE_REAL_H
#define ALTA_VALUE_REAL_H

#include "../domains/DiscreteDomain.hh"
#include "../domains/EnumDomain.hh"
#include "../domains/RealDomain.hh"
#include "Value.hh"
#include <boost/icl/continuous_interval.hpp>
#include <boost/icl/interval_set.hpp>
#include <boost/icl/rational.hpp>

namespace epoch {
    namespace altarica {


	using namespace boost::icl; 

	class ValueBool;
	class ValueSymbol;
	class ValueInt;

	typedef interval_set<double>  RealIntervals;
	


	class ValueReal : public Value {
	    
	protected:
	    
	    RealIntervals  values_;
	    const RealDomain *d_;
	    // std::size_t h_;
	    
	private:
	    // void rehash_();
	    const RealIntervals & getValues() const {return values_;}
	public:

	    virtual ~ValueReal();

	    virtual bool isReal()  const {return true;}

	    virtual ValueReal * clone() const;
	    virtual void inverse();
	    ValueReal();
	    ValueReal(const RealDomain *d);
	    ValueReal(double r);
	    ValueReal(const RealDomain *d, const RealIntervals& ri);
	    ValueReal(ValueInt *vi);


	    void setValue(double r);
	    int getMin() const;
	    int getMax() const;
	    void clear();

	    virtual void setDomain(const Domain *d);

	    virtual double toDouble() const;
	    virtual int toHash() const;

	    virtual bool equals(const ValueReal*v) const;	    

	    virtual void merge(const ValueReal*v);
	    virtual bool contains(const ValueReal *fi)const;	    

	    bool includes(const ValueReal* ii) const ;
	    void addValues(double min, double max, bool openright = false, bool openleft = false);
	    void removeValues(double min, double max, bool openright = false, bool openleft = false);
	    //	    void removeValues(const ValueReal *v);
	    virtual void intersectValue(const ValueReal* v);

	    void add(const ValueReal *i);
	    void minus(const ValueReal *i);
	    void times(const ValueReal *i);
	    void div(const ValueReal *i);
	    void mod(const ValueReal *i);
	    double max() const;
	    double min() const;
	    int card() const;
	    void realUnion(ValueReal *);
	    virtual ValueReal* getComplement() const;
	    void setToInfThan(ValueReal*);
	    void setToSupThan(ValueReal*);
	    void setToInfEqThan(ValueReal*);
	    void setToSupEqThan(ValueReal*);

	    virtual std::string toString() const;
	    virtual std::string toFiacre() const;

	    virtual std::vector<Value*> * getSingletons() const ;

	    virtual bool hasIntersection(const ValueReal*v)const;

	    virtual bool less(const ValueReal *v) const;
	    virtual bool less(const ValueSymbol *v) const {return false;}

	    virtual void removeValue(const ValueReal *v);

	    virtual bool pDifferent(const ValueReal *v) const;

	};
	




    }
}


#endif
