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

Last change on this file since 1845 was 1828, checked in by perderos, 24 years ago

Ajout du command executor pour trace de contour - Olivier 19/12/2001

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