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

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

Portage KCC (il faut functional pour less<>) Reza 5/8/99

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