#ifndef BENCH_IMPORT_H
#define BENCH_IMPORT_H

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

class BenchImport: public BenchParserClient, public Import {
    
    BenchParser parser_;
			      
    // ---- parameters 
	hub::Name designName_;					// if empty, no design generated
	hub::Name synthArchName_;				// ext arch name of the synthesized primitives
	hub::Name synthLibName_;				// library for existing primitives
    
    // ---- 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 list<std::string> listInputNames);
    void ParamsCheck (void);
    
public:
    // ---- import method
    virtual void operator() (const std::string& ="");
    virtual void operator() (hub::Library*,      const std::string& ="");
    virtual void operator() (hub::Entity*,       const std::string& ="");
    virtual void operator() (hub::Architecture*, const std::string& ="");

    BenchImport (hub::Hub* h, const std::string& fn="" ): 
    Import (h, fn), 
    parser_(this) {}

    BenchImport (hub::Library* lib, const std::string& fn="" ): 
    Import (lib, fn), 
    parser_(this) {}

    BenchImport (hub::Entity* ent, const std::string& fn="" ): 
    Import (ent, fn), 
    parser_(this) {}

    BenchImport (hub::Architecture* arch, const std::string& fn="" ): 
    Import (arch, fn), 
    parser_(this) {}

    ~BenchImport () {}

    // ---- parameters setting & getting
    std::string designName (void)     { return designName_; }
    std::string synthArchName (void)  { return synthArchName_; }	
    std::string synthLibName (void)   { return synthLibName_; }	

    void designName    (const std::string& s) { designName_ = s; }
    void synthArchName (const std::string& s) { synthArchName_ = s; }	
    void synthLibName  (const std::string& s) { synthLibName_ = s; }	

};

#endif

