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

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

Deplacement des methodes d'ajustement dans nouvelle classe Reza 6/8/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#if defined(__KCC__)
17using std::string ;
18#include <vector.h>
19#include <map.h>
20#include <functional.h>
21#endif
22
23#include "dlftypes.h"
24
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 ...
45class NamedObjMgr;
46class PIStdImgApp;
47class Timer;
48class PDynLinkMgr;
49
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="Command");
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 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
85 inline CmdExecutor* BaseExecutor() { return(basexec); }
86 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
87
88// Pour utilisation par PIAHelpWind uniquement
89 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
90
91protected:
92 virtual int CheckHelpGrp(string& grp);
93
94 NamedObjMgr* mObjMgr;
95 PIStdImgApp* mImgApp;
96
97 CmdInterpreter* curcmdi;
98 CmdExecutor* basexec;
99 CmdExecutor* fitexec;
100
101// Pour enregistrer la liste de commandes et leurs executeurs et le help
102 struct cmdex {int group; string us; CmdExecutor * cex; } ;
103 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
104 CmdHGroup cmdhgrp;
105 int cmdgrpid; // Numero de groupe courant
106 typedef map<string, cmdex, less<string> > CmdExmap;
107 CmdExmap cmdexmap;
108 CmdExmap helpexmap; // Pour les helps sans commande
109
110// Pour garder la liste des modules
111 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
112 Modmap modmap;
113
114// Pour garder la liste des interpreteur
115 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
116 InterpMap interpmap;
117
118// Pour stocker les variables definies par l'interpreteur
119 typedef map<string, string, less<string> > CmdVarList;
120 CmdVarList mVars; // Liste des variables
121 CmdVarList mAliases; // Liste des alias
122
123 PIACmdBloc * curblk; // Bloc de commande courant (foreach, ...)
124 int felevel; // foreah level
125
126 ofstream hist; // History file
127 bool histon; // True -> history file
128 bool trace; // Trace flag
129 bool timing; // Display CPU Time
130 Timer* gltimer; // pour Display CPU Time
131
132// Fenetre d'aide interactive
133 PIAHelpWind* helpwin;
134
135};
136
137
138
139#endif
Note: See TracBrowser for help on using the repository browser.