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

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

fenetre pour CxxExecutor - Reza 24/10/2000

File size: 4.4 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 <map>
15#include <functional>
16
17#include "dlftypes.h"
18#include "pdlmgr.h"
19
20
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
26 virtual int Execute(string& keyw, vector<string>& args)=0;
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 ...
40class NamedObjMgr;
41class PIStdImgApp;
42#ifdef SANS_EVOLPLANCK
43class Timer;
44#else
45namespace SOPHYA {
46class Timer;
47}
48#endif
49
50class PIAHelpWind; // Fenetre d'aide en ligne
51class CxxExecWind; // Fenetre pour CxxExecutor
52class CxxOptionWind; // Option de CxxExecutor
53
54class PIACmdBloc;
55
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// ---------------------------------------------------------------------
61
62
63class PIACmd : public CmdInterpreter {
64public:
65 static PIACmd* GetInterpreter();
66
67 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
68 virtual ~PIACmd();
69 virtual string Name();
70
71 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
72 string grp="Commands");
73 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
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);
80 virtual int ExecuteCommandLine(string& line);
81 virtual int ExecuteCommand(string& keyw, vector<string>& args);
82 virtual int ExecFile(string& file, vector<string>& args);
83
84 virtual string& GetUsage(const string& kw);
85
86 void ShowHelpWindow();
87 void ShowCxxOptionWindow();
88 void ShowCxxExecWindow();
89
90 virtual void HelptoLaTex(string const & flnm);
91
92 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
93 inline CmdExecutor* BaseExecutor() { return(basexec); }
94 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
95
96// Pour utilisation par PIAHelpWind uniquement
97 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
98
99protected:
100 virtual int CheckHelpGrp(string& grp);
101
102 NamedObjMgr* mObjMgr;
103 PIStdImgApp* mImgApp;
104
105 CmdInterpreter* curcmdi;
106 CmdExecutor* basexec; // basic command executor
107 CmdExecutor* fitexec; // Fit command executor
108 CmdExecutor* pawexec; // paw-like command executor
109 CmdExecutor* cxxexec; // on-line c++ compile/execution command executor
110
111// Pour enregistrer la liste de commandes et leurs executeurs et le help
112 struct cmdex {int group; string us; CmdExecutor * cex; } ;
113 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
114 CmdHGroup cmdhgrp;
115 int cmdgrpid; // Numero de groupe courant
116 typedef map<string, cmdex, less<string> > CmdExmap;
117 CmdExmap cmdexmap;
118 CmdExmap helpexmap; // Pour les helps sans commande
119
120// Pour garder la liste des modules
121 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
122 Modmap modmap;
123
124// Pour garder la liste des interpreteur
125 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
126 InterpMap interpmap;
127
128// Pour stocker les variables definies par l'interpreteur
129 typedef map<string, string, less<string> > CmdVarList;
130 CmdVarList mVars; // Liste des variables
131 CmdVarList mAliases; // Liste des alias
132
133 PIACmdBloc * curblk; // Bloc de commande courant (foreach, ...)
134 int felevel; // foreah level
135
136 ofstream hist; // History file
137 bool histon; // True -> history file
138 bool trace; // Trace flag
139 bool timing; // Display CPU Time
140 Timer* gltimer; // pour Display CPU Time
141
142// Fenetre d'aide interactive
143 PIAHelpWind* helpwin;
144 CxxExecWind* cxxexwin;
145 CxxOptionWind* cxxoptwin;
146};
147
148
149
150#endif
Note: See TracBrowser for help on using the repository browser.