#ifndef BENCH_IMPORT_H
#define BENCH_IMPORT_H

#include <list>
#include <string>
#include "hub/hub.h"
#include "hub/structural.h"
#include "hub/attr.h"
#include "hub/location.h"
#include "hub/symfunc.h"
#include "hub/named.h"

#include "import.h"
#include "bench_parser.h"

// ======================================================================================
class BenchImport: public BenchParserClient, public Import {
    
    BenchParser parser_;
    hub::Location dest_;
    hub::Location prim_;
    std::istream* in_;

    // ---- context 
    //hub::Library*		theSynthLib_;		// library for synthesized primitives
    //hub::Design*  	theDesign_;			// current design - for properties
    hub::StructArch*    theArchImpl_;		// current cell architecture implenetation
    hub::Instance* 		theInstance_;		// current instance
	
	// ----- gate keywords decodification 
	static hub::SymFunc::Func functions [LEX_MAX_FUNC-LEX_MIN_SYMFUNC+1];
	static hub::SymFunc::Func decode (int lsym) 
		{ return functions [lsym - LEX_MIN_SYMFUNC]; }

    // ---- names manipulation and generation
    static std::string consGateName (int gateNo);

protected:
    // ---- interface to semantic classes
    virtual void haveDesign (void);
    virtual void  endDesign (void);
    virtual void haveInPort  (const std::string& portName);
    virtual void haveOutPort (const std::string& portName);
    virtual void haveAssign (const std::string& OutputName, 
			     int function, 
                 const std::list <std::string> listInputNames);
    void ParamsCheck (void);
    
public:
    // ---- import method
    virtual void operator() (std::istream*, const std::string&, std::vector<hub::Location>&);

    BenchImport (hub::Hub* h): 
        parser_(this), dest_(h), prim_(h) {}
    ~BenchImport () {}
};

// ======================================================================================
class BenchImpLang: public ImportLang {
public:
    static void enregister (void);
    BenchImpLang (const std::string& n): ImportLang(n) {}
    Import* getImporter (hub::Hub* theHub) { return new BenchImport (theHub); }
    void    getDefaults (hub::Hub*, const std::string&, Import::Destinations&);
};

#endif

