/*******************************************************************************
 * Copyright (c) 2017 IRT AESE (IRT Saint Exupéry).
 * Ce logiciel est la propriété 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 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:
*     Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
*     
 *******************************************************************************/

/**
 * \class FiacreTranslator
 *
 * \ingroup PackageName
 * (Note, this needs exactly one \defgroup somewhere)
 *
 * \brief Provide an example
 *
 * This class contains all the printouts of the Altarica data structure
 * to a fiacre file.
 * Called in the main console.
 *
 * \note This file is part of the IRT MOISE project
 *
 * \author alexandre.albore $Author: bv $
 *
 * \version $Revision: 1.0 $
 *
 * \date $Date: 2016/10/27 09:16:20 $
 *
 * Contact: alexandre.albore@irt-saintexupery.com
 *
 * Created on: Wed Oct 27 09:16:20 2016
 *
 * $Id: doxygen-howto.html,v 1.0 2016/10/27 14:16:20 bv Exp $
 *
 */

#ifndef FIACRETRANSLATOR_HH_
#define FIACRETRANSLATOR_HH_

#include <iostream>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include <unordered_map>
#include <algorithm>
#include "Values.hh"
#include "AltaricaModel.hh"

namespace epoch {
    namespace altarica {

    class Value;

    class FiacreTranslator {

	private:
	    std::vector<Value*> stateVars_;
	    mutable std::vector<Value*> flowVars_;
	    const AltaricaModel * amodel_;
	  //  std::vector<Assertion*> * asserts_;

    protected:
    	std::ostringstream os_;
    	std::unordered_map<std::string,std::string> types_;
    	std::vector<std::string> flowtypes_;
    	const std::string UNDEF =  std::string("UNDEF");
    	std::string print_MandatoryEvents_sync (const std::vector<epoch::altarica::Event*> *ev, int n, std::ostringstream * s1, std::ostringstream * s2);
    	std::string print_OptionalEvents_sync (const std::vector<epoch::altarica::Event*> *ev, int n, std::ostringstream * s1, std::ostringstream * s2);
    	std::string print_assertions_function (std::vector<std::string> &vs, std::vector<std::string> &vf);
    	std::string print_transitions (epoch::altarica::Event &e, std::string &sconnect);
    	std::string print_metaEvents(const epoch::altarica::MetaEvent& e) ; //,std::string &sconnect

    public:
      //!
      FiacreTranslator(const AltaricaModel* amodel);

      ~FiacreTranslator();

      std::string getType(Value* dom);

      std::ostringstream *fiacre() {return &os_;}
      void printFiacre();
      const AltaricaModel &model() {return *amodel_;}
      std::string makesUnion(const std::vector<std::string>* sym);
      std::string removeAmp(std::string &r);
    };

}
}

#endif /* FIACRETRANSLATOR_HH_ */
