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

Last change on this file since 769 was 484, checked in by ercodmgr, 26 years ago

Ajout help et amelioration Help2TeX , Reza 21/10/99

File size: 4.0 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
19
20// Classe definissant l'interface pour un executeur de commande
21class CmdExecutor {
22public:
23 virtual ~CmdExecutor() {} ;
24 // keyw : Le mot cle associe , args: Arguments de la commande
25 virtual int Execute(string& keyw, vector<string>& args)=0;
26};
27
28// Classe definissant l'interface pour un interpreteur de commande
29class CmdInterpreter {
30public:
31 virtual ~CmdInterpreter() {} ;
32 virtual string Name()=0;
33 virtual int Interpret(string& line)=0;
34};
35
36
37
38// Forward declaration of some classes ...
39class NamedObjMgr;
40class PIStdImgApp;
41class Timer;
42class PDynLinkMgr;
43
44class PIAHelpWind; // Fenetre d'aide en ligne
45class PIACmdBloc;
46
47// ---------------------------------------------------------------------
48// Classe Interpreteur de commande, gestionnaire de module chargeable,
49// et de fonctions dynamiquement linke pour PIStdImgApp
50// Permet de gerer plusieurs Interpreter differents
51// ---------------------------------------------------------------------
52
53
54class PIACmd : public CmdInterpreter {
55public:
56 static PIACmd* GetInterpreter();
57
58 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
59 virtual ~PIACmd();
60 virtual string Name();
61
62 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
63 string grp="Commands");
64 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
65 virtual void LoadModule(string& fnameso, string& name);
66
67 virtual void AddInterpreter(CmdInterpreter * cl);
68 virtual void SelInterpreter(string& name);
69
70 virtual int Interpret(string& line);
71 virtual int ExecuteCommandLine(string& line);
72 virtual int ExecuteCommand(string& keyw, vector<string>& args);
73 virtual int ExecFile(string& file, vector<string>& args);
74
75 virtual string& GetUsage(const string& kw);
76 virtual void ShowHelpWindow();
77
78 virtual void HelptoLaTex(string const & flnm);
79
80 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
81 inline CmdExecutor* BaseExecutor() { return(basexec); }
82 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
83
84// Pour utilisation par PIAHelpWind uniquement
85 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
86
87protected:
88 virtual int CheckHelpGrp(string& grp);
89
90 NamedObjMgr* mObjMgr;
91 PIStdImgApp* mImgApp;
92
93 CmdInterpreter* curcmdi;
94 CmdExecutor* basexec;
95 CmdExecutor* fitexec;
96 CmdExecutor* pawexec;
97
98// Pour enregistrer la liste de commandes et leurs executeurs et le help
99 struct cmdex {int group; string us; CmdExecutor * cex; } ;
100 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
101 CmdHGroup cmdhgrp;
102 int cmdgrpid; // Numero de groupe courant
103 typedef map<string, cmdex, less<string> > CmdExmap;
104 CmdExmap cmdexmap;
105 CmdExmap helpexmap; // Pour les helps sans commande
106
107// Pour garder la liste des modules
108 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
109 Modmap modmap;
110
111// Pour garder la liste des interpreteur
112 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
113 InterpMap interpmap;
114
115// Pour stocker les variables definies par l'interpreteur
116 typedef map<string, string, less<string> > CmdVarList;
117 CmdVarList mVars; // Liste des variables
118 CmdVarList mAliases; // Liste des alias
119
120 PIACmdBloc * curblk; // Bloc de commande courant (foreach, ...)
121 int felevel; // foreah level
122
123 ofstream hist; // History file
124 bool histon; // True -> history file
125 bool trace; // Trace flag
126 bool timing; // Display CPU Time
127 Timer* gltimer; // pour Display CPU Time
128
129// Fenetre d'aide interactive
130 PIAHelpWind* helpwin;
131
132};
133
134
135
136#endif
Note: See TracBrowser for help on using the repository browser.