Changeset 2463 in Sophya for trunk/SophyaPI/PIext/piacmd.h
- Timestamp:
- Nov 27, 2003, 12:01:56 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piacmd.h
r2322 r2463 8 8 9 9 #include "machdefs.h" 10 #include <iostream> 11 #include <fstream> 10 #include "commander.h" 12 11 #include <string> 13 12 #include <vector> 14 #include <list>15 #include <stack>16 #include <map>17 #include <functional>18 13 19 14 #include "dlftypes.h" 20 #include "pdlmgr.h"21 #include "ctimer.h"22 23 // Classe definissant l'interface pour un executeur de commande24 class CmdExecutor {25 public:26 virtual ~CmdExecutor() {} ;27 // keyw : Le mot cle associe , args: Arguments de la commande28 virtual int Execute(string& keyw, vector<string>& args, string& toks)=0;29 };30 31 // Classe definissant l'interface pour un interpreteur de commande32 class CmdInterpreter {33 public:34 virtual ~CmdInterpreter() {} ;35 virtual string Name()=0;36 virtual int Interpret(string& line)=0;37 };38 39 40 15 41 16 // Forward declaration of some classes ... 42 17 class NamedObjMgr; 43 18 class PIStdImgApp; 44 #ifdef SANS_EVOLPLANCK45 class Timer;46 #else47 namespace SOPHYA {48 class Timer;49 }50 #endif51 19 52 20 class PIAHelpWind; // Fenetre d'aide en ligne 53 21 class CxxExecWind; // Fenetre pour CxxExecutor 54 22 class CxxOptionWind; // Option de CxxExecutor 55 56 class PIACmdBloc; // Bloc de type foreach / for de l'interpreteur PIACmd57 class PIACmdScript; // Script de commandes defini ds l'interpreteur PIACmd58 23 59 24 // --------------------------------------------------------------------- … … 64 29 65 30 66 class PIACmd : public C mdInterpreter {31 class PIACmd : public Commander { 67 32 public: 68 static PIACmd* GetInterpreter();33 // static PIACmd* GetInterpreter(); 69 34 70 35 PIACmd(NamedObjMgr* omg, PIStdImgApp* app); 71 36 virtual ~PIACmd(); 72 virtual string Name();73 37 74 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,75 string grp="Commands");76 virtual void RegisterHelp(string& keyw, string& usage, string& grp);77 virtual void LoadModule(string& fnameso, string& name);78 38 79 virtual void AddInterpreter(CmdInterpreter * cl); 80 virtual void SelInterpreter(string& name); 39 virtual int ExecuteCommandLine(string & kw, vector<string> & tokens, 40 string & toks); 41 void ShowHelpWindow(); 42 void ShowCxxOptionWindow(); 43 void ShowCxxExecWindow(); 81 44 82 virtual int Interpret(string& line); 83 virtual int ParseLineExecute(string& line, bool qw=true); 84 virtual int ExecuteCommand(string& keyw, vector<string>& args, string& toks); 85 virtual int ExecFile(string& file, vector<string>& args); 86 virtual int CShellExecute(string cmd); 87 virtual string& GetUsage(const string& kw); 45 // inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); } 88 46 89 void ShowHelpWindow();90 void ShowCxxOptionWindow();91 void ShowCxxExecWindow();92 93 virtual void HelptoLaTeX(string const & flnm);94 95 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }96 47 inline CmdExecutor* BaseExecutor() { return(basexec); } 97 48 inline CmdExecutor* ContExecutor() { return(cntexec); } //_OP_ … … 101 52 virtual void UpdateHelpList(PIAHelpWind* hw, int gid); 102 53 103 // Utilitaire pour decoupage en mot104 static int LineToWords(string& line, string& kw, vector<string>& tokens,105 string& toks, bool uq=true);106 54 protected: 107 55 virtual int CheckHelpGrp(string& grp); 108 int ExecuteCommandLine(string & keyw, vector<string> & args,109 string & toks);110 56 111 int SubstituteVars(string & s, string & s2); 112 int EvaluateTest(vector<string> & args, 113 string & line, bool & res); 114 int EvalRPNExpr(vector<string> & args, string & line); 115 116 bool GetVar(string & vn, string & vv); 117 void PushStack(vector<string> & args); 118 void PopStack(bool psta=true); 57 virtual void SetCurrentPrompt(const char* pr); 58 virtual void ShowMessage(const char * msg, int att); 119 59 120 60 NamedObjMgr* mObjMgr; 121 61 PIStdImgApp* mImgApp; 122 62 123 CmdInterpreter* curcmdi;124 63 CmdExecutor* basexec; // basic command executor 125 64 CmdExecutor* fitexec; // Fit command executor … … 130 69 CmdExecutor *flwexec; // flow chart executor _OP_ 131 70 132 // Pour enregistrer la liste de commandes et leurs executeurs et le help133 struct cmdex {int group; string us; CmdExecutor * cex; } ;134 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes135 CmdHGroup cmdhgrp;136 int cmdgrpid; // Numero de groupe courant137 typedef map<string, cmdex, less<string> > CmdExmap;138 CmdExmap cmdexmap;139 CmdExmap helpexmap; // Pour les helps sans commande140 141 // Pour garder la liste des modules142 typedef map<string, PDynLinkMgr* , less<string> > Modmap;143 Modmap modmap;144 145 // Pour garder la liste des interpreteur146 typedef map<string, CmdInterpreter*, less<string> > InterpMap;147 InterpMap interpmap;148 149 // Pour stocker les scripts definis ds l'interpreteur150 typedef map<string, PIACmdScript*, less<string> > ScriptList;151 ScriptList mScripts; // Liste des scripts152 PIACmdScript* curscript; // Script en cours de definition153 154 // Pour stocker les alias definies par l'interpreteur155 typedef map<string, string, less<string> > CmdStrList;156 CmdStrList mAliases; // Liste des alias157 158 // Le stack pour les arguments des .pic et des scripts159 stack< vector<string> > ArgsStack;160 161 stack< PIACmdBloc * > CmdBlks; // Bloc de commande courant (foreach, ...)162 int felevel; // foreach-for level163 stack< list<char> > TestsStack; // Stack des resultats de test164 list<char>::iterator tresit; // Test courant165 bool curtestresult; // Resultat courant des tests166 167 bool mulinefg; // Bloc multi-lignes (ligne suite)168 string mulinecmd; // Commande multi-lignes169 string spromptmul; // Prompt console avant multi-ligne170 171 ofstream hist; // History file172 bool histon; // True -> history file173 bool trace; // Trace flag174 bool timing; // Display CPU Time175 Timer* gltimer; // pour Display CPU Time176 177 71 // Fenetre d'aide interactive 178 72 PIAHelpWind* helpwin;
Note:
See TracChangeset
for help on using the changeset viewer.