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

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

A/ ajout des blocs foreach et ameliorations gestion des variables ($x)
pour l'interpreteur piacmd.
B/ Ajout PIStdImgApp::AddText et corrections diverses

Reza 05/08/99

File size: 3.9 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>
[165]14#include <map>
15#if defined(__KCC__)
16using std::string ;
[293]17#include <vector.h>
[165]18#include <map.h>
19#endif
20
21#include "dlftypes.h"
22
[293]23
24// Classe definissant l'interface pour un executeur de commande
25class CmdExecutor {
26public:
27 virtual ~CmdExecutor() {} ;
28 // keyw : Le mot cle associe , args: Arguments de la commande
29 virtual int Execute(string& keyw, vector<string>& args)=0;
30};
31
32// Classe definissant l'interface pour un interpreteur de commande
33class CmdInterpreter {
34public:
35 virtual ~CmdInterpreter() {} ;
36 virtual string Name()=0;
37 virtual int Interpret(string& line)=0;
38};
39
40
41
42// Forward declaration of some classes ...
[165]43class NamedObjMgr;
44class PIStdImgApp;
[293]45class Timer;
46class PDynLinkMgr;
[165]47
[349]48class PIAHelpWind; // Fenetre d'aide en ligne
49class PIACmdBloc;
50
[293]51// ---------------------------------------------------------------------
52// Classe Interpreteur de commande, gestionnaire de module chargeable,
53// et de fonctions dynamiquement linke pour PIStdImgApp
54// Permet de gerer plusieurs Interpreter differents
55// ---------------------------------------------------------------------
[165]56
[330]57
[293]58class PIACmd : public CmdInterpreter {
[165]59public:
[293]60 static PIACmd* GetInterpreter();
[165]61
[293]62 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
63 virtual ~PIACmd();
64 virtual string Name();
65
[330]66 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
67 string grp="Command");
68 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
[293]69 virtual void LoadModule(string& fnameso, string& name);
70
71 virtual void AddInterpreter(CmdInterpreter * cl);
72 virtual void SelInterpreter(string& name);
73
74 virtual int Interpret(string& line);
[333]75 virtual int ExecuteCommandLine(string& line);
76 virtual int ExecuteCommand(string& keyw, vector<string>& args);
[349]77 virtual int ExecFile(string& file, vector<string>& args);
[293]78
79 virtual string& GetUsage(const string& kw);
80 virtual void ShowHelpWindow();
81
82 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
83 inline CmdExecutor* BaseExecutor() { return(basexec); }
84 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
85
[330]86// Pour utilisation par PIAHelpWind uniquement
87 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
88
[293]89protected:
[330]90 virtual int CheckHelpGrp(string& grp);
91
[165]92 NamedObjMgr* mObjMgr;
93 PIStdImgApp* mImgApp;
94
[293]95 CmdInterpreter* curcmdi;
96 CmdExecutor* basexec;
97
[330]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
[293]103 typedef map<string, cmdex, less<string> > CmdExmap;
104 CmdExmap cmdexmap;
[330]105 CmdExmap helpexmap; // Pour les helps sans commande
[293]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
[165]115// Pour stocker les variables definies par l'interpreteur
[293]116 typedef map<string, string, less<string> > CmdVarList;
[349]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
[165]123 ofstream hist; // History file
[349]124 bool histon; // True -> history file
[165]125 bool trace; // Trace flag
126 bool timing; // Display CPU Time
127 Timer* gltimer; // pour Display CPU Time
128
[293]129// Fenetre d'aide interactive
130 PIAHelpWind* helpwin;
[165]131
132};
133
[293]134
135
[165]136#endif
Note: See TracBrowser for help on using the repository browser.