#ifndef EDIF_IMPORT_H
#define EDIF_IMPORT_H
#include <string>
#include <list>
#include "edif_parser.h"
#include "hub.h"
#include "structural.h"
#include "attr.h"
#include "import.h"
#include "location.h"
#include "named.h"

class EdifImport: public EdifParserClient, public Import {
    EdifParser parser_;

    // ---------------- context other than Location ----------------------------------
    enum { ExtCtx, DefCtx } libCtx_;		// is this an external or defined library
    hub::Design*  	theDesign_;		// current design - for properties
    hub::StructArch*    theArchImpl_;		// current structure
    hub::number_t  	portNum_;		// port no of current view
    hub::Instance* 	theInstance_;		// current instance
    hub::Net*		theNet_;		// current net
    hub::PortProto*	thePort_;		// actual port prototype
    hub::Port <hub::StructArch>* theArchPort_;	// its instance in the struct arch

protected:
    virtual void haveLibrary     (std::string libname);
    virtual void  endLibrary     (void);
    virtual void haveExternal    (std::string libname);
    virtual void  endExternal    (void);
    virtual void haveDesign      (std::string designName, std::string cellName, std::string libName);
    virtual void  endDesign      (void);
    virtual void haveCell        (std::string cellName);
    virtual void  endCell        (void);
    virtual void haveView        (std::string viewName);
    virtual void  endView        (void);
    virtual void havePort        (std::string portName);
    virtual void endPort	 (void);
    virtual void haveDir	 (std::string portDir);
    virtual void haveInstance    (std::string instDims, std::string viewName, std::string cellName, std::string libName);
    virtual void  endInstance    (void);    
    virtual bool wantProperty      (propCtx, std::string propName);
    virtual void haveStrProperty   (propCtx, std::string propName, std::string propValue);
    virtual void haveBoolProperty  (propCtx, std::string propName, bool propValue);
    virtual void haveIntProperty   (propCtx, std::string propName, int propValue);
    virtual void haveNet         (std::string netName);
    virtual void  endNet         (void);
    virtual void haveJoined      (std::string portName, std::string instName);

    static const hub :: PortProto :: flagsType&  DecodeDir (const std::string&);
public:
    virtual void operator() (const std::string& ="");
    virtual void operator() (hub::Library*,      const std::string& ="");	// filtering ops
    virtual void operator() (hub::Entity*,       const std::string& ="");
    virtual void operator() (hub::Architecture*, const std::string& ="");


    EdifImport (hub::Hub* h): Import(h), parser_ (this) {}
    EdifImport (hub::Hub* h, const std::string& fn): Import (h, fn), parser_ (this) {}
    //
    //		other Location capabilities unused
    //
    ~EdifImport () {}
    
};
#endif

