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

#include <set>
#include <vector>
#include <string>

namespace epoch {
    namespace altarica {

	class MemberAccess;
	class Expression;
	class Node;
	class AltaricaModel; 
	class AltaricaState;
    
	//! EVENT
	/*!
	  Stucture pour stocker les event et leur priorite
	 */
	typedef enum LawType {
	    ALTARICA_DISCRETE,
	    ALTARICA_DIRAC_0,
	    ALTARICA_EXP,
		ALTARICA_TIMED
	} LawType;

	class EventLaw {

	    
	    
	protected:
	    
	    //! 
	    // std::string *eventName_;
	    //! full qualified name
	    MemberAccess *ma_;
	    LawType type_;
	    //double param_;
	    Expression * param1_;
	    Expression * param2_;
	    Node *n_;
	    
	public:

	    //! 
	    // EventLaw(std::string *name);
	    // EventLaw(std::string *name, LawType t, double p);
	    ~EventLaw();
	    EventLaw(MemberAccess *ma) : ma_(ma), n_(NULL), param1_(NULL), param2_(NULL) {}
	    EventLaw(MemberAccess *ma, LawType t, Expression * p) : ma_(ma), type_(t), param1_(p), param2_(NULL), n_(NULL) {}
	    EventLaw(MemberAccess *ma, LawType t, Expression * p, Expression * q) : ma_(ma), type_(t), param1_(p), param2_(q), n_(NULL) {}
	    EventLaw(LawType t, Expression * p = NULL, Expression * q = NULL) : ma_(NULL), type_(t), param1_(p), param2_(q), n_(NULL) {}
	    
	    // void setName(std::string *name);
	    void setMA(MemberAccess *ma) {ma_ = ma;}
	    void setType(LawType t) {type_=t;}
	    void setParam(Expression *e) {param1_ = e;}
	    Expression * getParam() const {return param1_;}
	    Expression * getStartParam() const {return param1_;}
	    Expression * getEndParam() const {return param2_;}

	    double evalParam(const AltaricaModel *am, AltaricaState *s) const;
	    bool isDisabled() const;
	    bool isDirac() const;
	    bool isDiscrete() const;
	    bool isCont() const;
	    bool isTimed() const;
	    void setNode(Node *n) {n_ = n;}

	    const MemberAccess* getMA() const {return ma_;}
	    
	    std::string toString() const;

	    EventLaw * clone() const;

    void deleteExpr();
    
	};
    }
}

#endif
