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

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

Adaptation aux "normes DPC", introduction des classes CmdExecutor, ...
Fenetre d'aide en lignes, gestion de modules, ... Reza 11/05/99

File size: 3.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>
[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;
47class PIAHelpWind;
[165]48
[293]49// ---------------------------------------------------------------------
50// Classe Interpreteur de commande, gestionnaire de module chargeable,
51// et de fonctions dynamiquement linke pour PIStdImgApp
52// Permet de gerer plusieurs Interpreter differents
53// ---------------------------------------------------------------------
[165]54
[293]55class PIACmd : public CmdInterpreter {
[165]56public:
[293]57 static PIACmd* GetInterpreter();
[165]58
[293]59 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
60 virtual ~PIACmd();
61 virtual string Name();
62
63 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce);
64 virtual void LoadModule(string& fnameso, string& name);
65
66 virtual void AddInterpreter(CmdInterpreter * cl);
67 virtual void SelInterpreter(string& name);
68
69 virtual int Interpret(string& line);
70 virtual int ExecFile(string& file);
71
72 virtual string& GetUsage(const string& kw);
73 virtual void ShowHelpWindow();
74
75 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
76 inline CmdExecutor* BaseExecutor() { return(basexec); }
77 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
78
79protected:
[165]80 NamedObjMgr* mObjMgr;
81 PIStdImgApp* mImgApp;
82
[293]83 CmdInterpreter* curcmdi;
84 CmdExecutor* basexec;
85
86// Pour enregistrer la liste de commandes et leurs executeurs
87 struct cmdex {string us; CmdExecutor * cex; } ;
88 typedef map<string, cmdex, less<string> > CmdExmap;
89 CmdExmap cmdexmap;
90
91// Pour garder la liste des modules
92 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
93 Modmap modmap;
94
95// Pour garder la liste des interpreteur
96 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
97 InterpMap interpmap;
98
[165]99// Pour stocker les variables definies par l'interpreteur
[293]100 typedef map<string, string, less<string> > CmdVarList;
[165]101 CmdVarList mVars; // Liste des variables
102 ofstream hist; // History file
103 bool trace; // Trace flag
104 bool timing; // Display CPU Time
105 Timer* gltimer; // pour Display CPU Time
106
[293]107// Fenetre d'aide interactive
108 PIAHelpWind* helpwin;
[165]109
110};
111
[293]112
113
[165]114#endif
Note: See TracBrowser for help on using the repository browser.