/*******************************************************************************
* 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:
*     Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
*     
 *******************************************************************************/

#ifndef ALTA_VALUE_INT_H
#define ALTA_VALUE_INT_H

#include "../domains/DiscreteDomain.hh"
#include "../domains/EnumDomain.hh"
#include <set>
#include "Value.hh"

namespace epoch {
    namespace altarica {

	class ValueBool;
	class ValueSymbol;

	typedef struct IntInterval {
	    int min;
	    int max;
	} IntInterval;
	


	class ValueInt : public Value {
	    
	protected:
	    
	    std::vector<IntInterval*> * values_;
	    const DiscreteDomain *d_;
	    // std::size_t h_;
	    
	private:
	    // void rehash_();
	public:

	    virtual ~ValueInt();

	    virtual bool isInt()  const {return true;}

	    virtual ValueInt * clone() const;
	    virtual void inverse();
	    ValueInt();
	    ValueInt(const DiscreteDomain *d);
	    ValueInt(int i);

	    void setValue(int i);
	    int getMin() const;
	    int getMax() const;
	    void clear();

	    virtual void setDomain(const Domain *d);
	    const DiscreteDomain * getDomain() const {return d_;}

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

	    virtual bool equals(const ValueInt*v) const;	    

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

	    bool includes(IntInterval* ii) const ;
	    bool isIncluded(IntInterval*ii) const;
	    bool includes(std::vector<IntInterval*>* v) const;
	    bool isIncluded(std::vector<IntInterval*>*v) const;
	    void addValues(int min, int max);
	    void removeValues(int min, int max);
	    virtual void intersectValue(const ValueInt* v);

	    const std::vector<IntInterval*> * getValues() const;
	    void add(const ValueInt *i);
	    void minus(const ValueInt *i);
	    void times(const ValueInt *i);
	    void div(const ValueInt *i);
	    void mod(const ValueInt *i);
	    int max() const;
	    int min() const;
	    int card() const;
	    void intUnion(ValueInt *);
	    virtual ValueInt* getComplement() const;
	    void setToInfThan(ValueInt*);
	    void setToSupThan(ValueInt*);
	    void setToInfEqThan(ValueInt*);
	    void setToSupEqThan(ValueInt*);

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

	    virtual bool hasIntersection(const ValueInt*v)const;

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

	    virtual void removeValue(const ValueInt *v);

	    virtual bool pDifferent(const ValueInt *v) const;


	};
	




    }
}


#endif
