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

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

Petite adaptation aux namespace - Reza 12/4/2000

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