source: Sophya/trunk/SophyaPI/PIext/piacmd.h@ 2214

Last change on this file since 2214 was 2214, checked in by ansari, 23 years ago

Gestion des arguments des .pic (-tcsh ...) dans un stack , separe de la liste des variables , Reza 17/10/02

File size: 5.6 KB
RevLine 
[165]1// This may look like C code, but it is really -*- C++ -*-
2// Classe interpreteur de commande pour piapp
3// Reza Aout 97 , Juillet,Aout 98
4// LAL-IN2P3/CNRS
5
6#ifndef PIACMD_H_SEEN
7#define PIACMD_H_SEEN
8
[293]9#include "machdefs.h"
10#include <iostream.h>
[165]11#include <fstream.h>
12#include <string>
[293]13#include <vector>
[1262]14#include <list>
[2214]15#include <stack>
[165]16#include <map>
[351]17#include <functional>
[165]18
19#include "dlftypes.h"
[912]20#include "pdlmgr.h"
[1920]21#include "ctimer.h"
[165]22
[293]23// Classe definissant l'interface pour un executeur de commande
24class CmdExecutor {
25public:
26 virtual ~CmdExecutor() {} ;
27 // keyw : Le mot cle associe , args: Arguments de la commande
[1268]28 virtual int Execute(string& keyw, vector<string>& args, string& toks)=0;
[293]29};
30
31// Classe definissant l'interface pour un interpreteur de commande
32class CmdInterpreter {
33public:
34 virtual ~CmdInterpreter() {} ;
35 virtual string Name()=0;
36 virtual int Interpret(string& line)=0;
37};
38
39
40
41// Forward declaration of some classes ...
[165]42class NamedObjMgr;
43class PIStdImgApp;
[897]44#ifdef SANS_EVOLPLANCK
[293]45class Timer;
[897]46#else
47namespace SOPHYA {
48class Timer;
49}
50#endif
[1251]51
52class PIAHelpWind; // Fenetre d'aide en ligne
53class CxxExecWind; // Fenetre pour CxxExecutor
54class CxxOptionWind; // Option de CxxExecutor
55
[2214]56class PIACmdBloc; // Bloc de type foreach / for de l'interpreteur PIACmd
57class PIACmdScript; // Script de commandes defini ds l'interpreteur PIACmd
[349]58
[293]59// ---------------------------------------------------------------------
60// Classe Interpreteur de commande, gestionnaire de module chargeable,
61// et de fonctions dynamiquement linke pour PIStdImgApp
62// Permet de gerer plusieurs Interpreter differents
63// ---------------------------------------------------------------------
[165]64
[330]65
[293]66class PIACmd : public CmdInterpreter {
[165]67public:
[293]68 static PIACmd* GetInterpreter();
[165]69
[293]70 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
71 virtual ~PIACmd();
72 virtual string Name();
73
[330]74 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
[484]75 string grp="Commands");
[330]76 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
[293]77 virtual void LoadModule(string& fnameso, string& name);
78
79 virtual void AddInterpreter(CmdInterpreter * cl);
80 virtual void SelInterpreter(string& name);
81
82 virtual int Interpret(string& line);
[1262]83 virtual int ParseLineExecute(string& line);
[1268]84 virtual int ExecuteCommand(string& keyw, vector<string>& args, string& toks);
[349]85 virtual int ExecFile(string& file, vector<string>& args);
[2203]86 virtual int CShellExecute(string cmd);
[293]87 virtual string& GetUsage(const string& kw);
88
[1251]89 void ShowHelpWindow();
90 void ShowCxxOptionWindow();
91 void ShowCxxExecWindow();
92
[463]93 virtual void HelptoLaTex(string const & flnm);
94
[293]95 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
96 inline CmdExecutor* BaseExecutor() { return(basexec); }
[1828]97 inline CmdExecutor* ContExecutor() { return(cntexec); } //_OP_
[293]98 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
99
[330]100// Pour utilisation par PIAHelpWind uniquement
101 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
102
[293]103protected:
[330]104 virtual int CheckHelpGrp(string& grp);
[1262]105 int ExecuteCommandLine(string & keyw, vector<string> & args,
106 string & toks);
[330]107
[1262]108 int SubstituteVars(string & s, string & s2);
[1565]109 int EvaluateTest(vector<string> & args,
110 string & line, bool & res);
[2214]111 bool GetVar(string & vn, string & vv);
[1262]112
[165]113 NamedObjMgr* mObjMgr;
114 PIStdImgApp* mImgApp;
115
[293]116 CmdInterpreter* curcmdi;
[1224]117 CmdExecutor* basexec; // basic command executor
118 CmdExecutor* fitexec; // Fit command executor
119 CmdExecutor* pawexec; // paw-like command executor
120 CmdExecutor* cxxexec; // on-line c++ compile/execution command executor
[293]121
[1828]122 CmdExecutor *cntexec; // contour executor _OP_
[1920]123 CmdExecutor *flwexec; // flow chart executor _OP_
[1828]124
[330]125// Pour enregistrer la liste de commandes et leurs executeurs et le help
126 struct cmdex {int group; string us; CmdExecutor * cex; } ;
127 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
128 CmdHGroup cmdhgrp;
129 int cmdgrpid; // Numero de groupe courant
[293]130 typedef map<string, cmdex, less<string> > CmdExmap;
131 CmdExmap cmdexmap;
[330]132 CmdExmap helpexmap; // Pour les helps sans commande
[293]133
134// Pour garder la liste des modules
135 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
136 Modmap modmap;
137
138// Pour garder la liste des interpreteur
139 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
140 InterpMap interpmap;
141
[2214]142// Pour stocker les scripts definis ds l'interpreteur
143 typedef map<string, PIACmdScript*, less<string> > ScriptList;
144 ScriptList mScripts; // Liste des scripts
[349]145
[2214]146// Pour stocker les alias definies par l'interpreteur
147 typedef map<string, string, less<string> > CmdStrList;
148 CmdStrList mAliases; // Liste des alias
149
150// Le stack pour les arguments des .pic et des scripts
151 stack< vector<string> > ArgsStack;
152
[349]153 PIACmdBloc * curblk; // Bloc de commande courant (foreach, ...)
154 int felevel; // foreah level
[1565]155 list<char> testresult; // Resultat des test if
156 list<char>::iterator tresit; // Test courant
[1276]157 bool mulinefg; // Bloc multi-lignes (ligne suite)
158 string mulinecmd; // Commande multi-lignes
[349]159
[165]160 ofstream hist; // History file
[349]161 bool histon; // True -> history file
[165]162 bool trace; // Trace flag
163 bool timing; // Display CPU Time
164 Timer* gltimer; // pour Display CPU Time
165
[293]166// Fenetre d'aide interactive
167 PIAHelpWind* helpwin;
[1251]168 CxxExecWind* cxxexwin;
169 CxxOptionWind* cxxoptwin;
[165]170};
171
[293]172
173
[165]174#endif
Note: See TracBrowser for help on using the repository browser.