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

Last change on this file since 1268 was 1268, checked in by ercodmgr, 25 years ago

3ieme argument string& toks pour Execute et ExecuteCommand
preparation gestion TmpDir dans cxxexecutor
suppression de ExecuteCXX ds cxxexecutor et appels
possibilite d'ajouter des userfct.cc ds cxxexecutor

cmv 1/11/00

File size: 4.9 KB
Line 
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
9#include "machdefs.h"
10#include <iostream.h>
11#include <fstream.h>
12#include <string>
13#include <vector>
14#include <list>
15#include <map>
16#include <functional>
17
18#include "dlftypes.h"
19#include "pdlmgr.h"
20
21
22// Classe definissant l'interface pour un executeur de commande
23class CmdExecutor {
24public:
25 virtual ~CmdExecutor() {} ;
26 // keyw : Le mot cle associe , args: Arguments de la commande
27 virtual int Execute(string& keyw, vector<string>& args, string& toks)=0;
28};
29
30// Classe definissant l'interface pour un interpreteur de commande
31class CmdInterpreter {
32public:
33 virtual ~CmdInterpreter() {} ;
34 virtual string Name()=0;
35 virtual int Interpret(string& line)=0;
36};
37
38
39
40// Forward declaration of some classes ...
41class NamedObjMgr;
42class PIStdImgApp;
43#ifdef SANS_EVOLPLANCK
44class Timer;
45#else
46namespace SOPHYA {
47class Timer;
48}
49#endif
50
51class PIAHelpWind; // Fenetre d'aide en ligne
52class CxxExecWind; // Fenetre pour CxxExecutor
53class CxxOptionWind; // Option de CxxExecutor
54
55class PIACmdBloc;
56
57// ---------------------------------------------------------------------
58// Classe Interpreteur de commande, gestionnaire de module chargeable,
59// et de fonctions dynamiquement linke pour PIStdImgApp
60// Permet de gerer plusieurs Interpreter differents
61// ---------------------------------------------------------------------
62
63
64class PIACmd : public CmdInterpreter {
65public:
66 static PIACmd* GetInterpreter();
67
68 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
69 virtual ~PIACmd();
70 virtual string Name();
71
72 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
73 string grp="Commands");
74 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
75 virtual void LoadModule(string& fnameso, string& name);
76
77 virtual void AddInterpreter(CmdInterpreter * cl);
78 virtual void SelInterpreter(string& name);
79
80 virtual int Interpret(string& line);
81 virtual int ParseLineExecute(string& line);
82 virtual int ExecuteCommand(string& keyw, vector<string>& args, string& toks);
83 virtual int ExecFile(string& file, vector<string>& args);
84
85 virtual string& GetUsage(const string& kw);
86
87 void ShowHelpWindow();
88 void ShowCxxOptionWindow();
89 void ShowCxxExecWindow();
90
91 virtual void HelptoLaTex(string const & flnm);
92
93 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
94 inline CmdExecutor* BaseExecutor() { return(basexec); }
95 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
96
97// Pour utilisation par PIAHelpWind uniquement
98 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
99
100protected:
101 virtual int CheckHelpGrp(string& grp);
102 int ExecuteCommandLine(string & keyw, vector<string> & args,
103 string & toks);
104
105 int SubstituteVars(string & s, string & s2);
106 bool EvaluateTest(vector<string> & args);
107
108 NamedObjMgr* mObjMgr;
109 PIStdImgApp* mImgApp;
110
111 CmdInterpreter* curcmdi;
112 CmdExecutor* basexec; // basic command executor
113 CmdExecutor* fitexec; // Fit command executor
114 CmdExecutor* pawexec; // paw-like command executor
115 CmdExecutor* cxxexec; // on-line c++ compile/execution command executor
116
117// Pour enregistrer la liste de commandes et leurs executeurs et le help
118 struct cmdex {int group; string us; CmdExecutor * cex; } ;
119 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
120 CmdHGroup cmdhgrp;
121 int cmdgrpid; // Numero de groupe courant
122 typedef map<string, cmdex, less<string> > CmdExmap;
123 CmdExmap cmdexmap;
124 CmdExmap helpexmap; // Pour les helps sans commande
125
126// Pour garder la liste des modules
127 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
128 Modmap modmap;
129
130// Pour garder la liste des interpreteur
131 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
132 InterpMap interpmap;
133
134// Pour stocker les variables definies par l'interpreteur
135 typedef map<string, string, less<string> > CmdVarList;
136 // CmdVarList mVars; Liste des variables
137 CmdVarList mAliases; // Liste des alias
138
139 PIACmdBloc * curblk; // Bloc de commande courant (foreach, ...)
140 int felevel; // foreah level
141 list<bool> testresult; // Resultat des test if
142 list<bool>::iterator tresit; // Test courant
143 bool bloctest; // On est ds un bloc test
144 bool bloccxx; // On est ds un bloc code C++
145 string codecxx;
146
147 ofstream hist; // History file
148 bool histon; // True -> history file
149 bool trace; // Trace flag
150 bool timing; // Display CPU Time
151 Timer* gltimer; // pour Display CPU Time
152
153// Fenetre d'aide interactive
154 PIAHelpWind* helpwin;
155 CxxExecWind* cxxexwin;
156 CxxOptionWind* cxxoptwin;
157};
158
159
160
161#endif
Note: See TracBrowser for help on using the repository browser.