/*******************************************************************************
 * 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 ALTARICA_MEV_HH
#define ALTARICA_MEV_HH

#include <vector>
#include <string>

namespace epoch {
	namespace altarica {

	    class AltaricaState;
	    class AltaricaModel;
	    class Event;
	    
	    
	    		//! meta event class : synchronised atomic events
	    class MetaEvent {

	    private:

	    	std::vector<Event*> *events_;
	    	double proba_;
	    	double reward_;

	    public:

	    	MetaEvent();
	    	~MetaEvent();
	    	MetaEvent(std::vector<Event*> *v);
	    	void push_back(Event* e);
	    	bool containsE(const Event* e) const;
	    	unsigned int size();
	    	bool add(MetaEvent* m);
	    	 std::vector<Event*> * getEvents() const {return events_;}
	    	int comparePrioTo(MetaEvent* other);
	    	bool eventIn(Event *e);
	    	double getProba() const {return proba_;}
	    	void setProba(double p) {proba_ = p;}
	    	double getReward() const {return reward_;}
	    	void setReward(double r) {reward_ = r;}
	    	double timesDiscreteProba(AltaricaModel *am, AltaricaState *as);
	    	double timesDiscreteProba(double p);
	    	double complementOthersProba(std::vector<const Event*> * allEvents,	 AltaricaModel *am, AltaricaState *as);
	    	void setMaxContProba(AltaricaModel *am, AltaricaState *as);
	    	MetaEvent * clone() const;
	    	inline bool isEmpty() {return events_->size() == 0;}

	    	bool isEnabled(const AltaricaModel *am, AltaricaState *s) const;
	    	bool equals(const MetaEvent * mev) const;
	    	bool contains(const MetaEvent* mev) const ;


	    	bool isDirac() const;
	    	static MetaEvent* unionMetaEvents(std::vector<MetaEvent*> *metavec);
	    	static std::vector<MetaEvent*>* combineMetaEvents(std::vector<MetaEvent*> *metavec);
	    	static bool addMEV(std::vector<MetaEvent*> *list, MetaEvent *mev);
	    	static std::vector<MetaEvent*>* buildVec(std::vector<std::vector<Event*>*>* v);
	    	std::string toString();
	    };	    	    
	}
}
#endif
