// This may look like C code, but it is really -*- C++ -*- // Classe interpreteur de commande pour piapp // Reza Aout 97 , Juillet,Aout 98 // LAL-IN2P3/CNRS #ifndef PIACMD_H_SEEN #define PIACMD_H_SEEN #include "machdefs.h" #include #include #include #include #include #if defined(__KCC__) using std::string ; #include #include #endif #include "dlftypes.h" // Classe definissant l'interface pour un executeur de commande class CmdExecutor { public: virtual ~CmdExecutor() {} ; // keyw : Le mot cle associe , args: Arguments de la commande virtual int Execute(string& keyw, vector& args)=0; }; // Classe definissant l'interface pour un interpreteur de commande class CmdInterpreter { public: virtual ~CmdInterpreter() {} ; virtual string Name()=0; virtual int Interpret(string& line)=0; }; // Forward declaration of some classes ... class NamedObjMgr; class PIStdImgApp; class Timer; class PDynLinkMgr; class PIAHelpWind; // --------------------------------------------------------------------- // Classe Interpreteur de commande, gestionnaire de module chargeable, // et de fonctions dynamiquement linke pour PIStdImgApp // Permet de gerer plusieurs Interpreter differents // --------------------------------------------------------------------- class PIACmd : public CmdInterpreter { public: static PIACmd* GetInterpreter(); PIACmd(NamedObjMgr* omg, PIStdImgApp* app); virtual ~PIACmd(); virtual string Name(); virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce); virtual void LoadModule(string& fnameso, string& name); virtual void AddInterpreter(CmdInterpreter * cl); virtual void SelInterpreter(string& name); virtual int Interpret(string& line); virtual int ExecFile(string& file); virtual string& GetUsage(const string& kw); virtual void ShowHelpWindow(); inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); } inline CmdExecutor* BaseExecutor() { return(basexec); } inline PIStdImgApp* GetImgApp() { return(mImgApp); } protected: NamedObjMgr* mObjMgr; PIStdImgApp* mImgApp; CmdInterpreter* curcmdi; CmdExecutor* basexec; // Pour enregistrer la liste de commandes et leurs executeurs struct cmdex {string us; CmdExecutor * cex; } ; typedef map > CmdExmap; CmdExmap cmdexmap; // Pour garder la liste des modules typedef map > Modmap; Modmap modmap; // Pour garder la liste des interpreteur typedef map > InterpMap; InterpMap interpmap; // Pour stocker les variables definies par l'interpreteur typedef map > CmdVarList; CmdVarList mVars; // Liste des variables ofstream hist; // History file bool trace; // Trace flag bool timing; // Display CPU Time Timer* gltimer; // pour Display CPU Time // Fenetre d'aide interactive PIAHelpWind* helpwin; }; #endif