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

#include <vector>
#include <map>
#include <string>


namespace epoch {
    namespace altarica {
    
	class Node;
	class Assignment;
	class MemberAccess;
	class Event;
	class Expression;
	class AltaricaState;
	class AltaricaModel;
	
	class Transition {
	    
	protected:
	    
	    //! precondition associee a la transition
	    Expression *precond_;
	    
	    //! liste des evenements concernes
	    std::vector<Event*> eventList_;

	    std::vector<Assignment*> assignmentList_;

	    std::vector<MemberAccess*> eventNames_;
	    

	    Node * node_;

	    //	    std::vector<Variable*> * stateVarsInPrecond;
	    // std::map<int, int> indexVarTranslator;
	public:

	    //! 
	    Transition(Expression *precond);
	    Transition();
	    ~Transition();

	    void setPrecond(Expression *precond);
	    const Expression * getPrecond() const {return precond_; }
	    void addEvent(Event* e);
	    void addEvents(std::vector<Event*>* ve);
	    void addAssignment(Assignment* a);
	    void addAssignments(std::vector<Assignment*> * va);
	    const std::vector<Assignment*> * getAssigns() const {return &assignmentList_;}
	    void addEventName(MemberAccess *ma);
	    void addEventNames(std::vector<MemberAccess*> *mav);
	    Transition * clone();

	    void setNode(Node*n);
	    const Node* getNode() const {return node_;}

	    void matchEvents();

	    bool precondOK(const AltaricaModel *am, AltaricaState *s) const;

	    void doTransition(const AltaricaModel *am, AltaricaState *s, AltaricaState *ns);

	    //	    void cachePrecond();


	    void deleteExprs();

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

	};
    }
}

#endif
