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

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

Trace de NTuple en 2D avec Marker de taille proportionnelle a Weight
Introduction des repertoires dans la gestion d'objets NameObjMgr
Reorganisation NamedObjMgr et Services2NObjMgr, ajout de commandes , ...
Reza 12/7/99

File size: 3.7 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#if defined(__KCC__)
16using std::string ;
17#include <vector.h>
18#include <map.h>
19#endif
20
21#include "dlftypes.h"
22
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 ...
43class NamedObjMgr;
44class PIStdImgApp;
45class Timer;
46class PDynLinkMgr;
47class PIAHelpWind;
48
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// ---------------------------------------------------------------------
54
55class PIAHelpWind; // Fenetre d'aide en ligne
56
57class PIACmd : public CmdInterpreter {
58public:
59 static PIACmd* GetInterpreter();
60
61 PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
62 virtual ~PIACmd();
63 virtual string Name();
64
65 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
66 string grp="Command");
67 virtual void RegisterHelp(string& keyw, string& usage, string& grp);
68 virtual void LoadModule(string& fnameso, string& name);
69
70 virtual void AddInterpreter(CmdInterpreter * cl);
71 virtual void SelInterpreter(string& name);
72
73 virtual int Interpret(string& line);
74 virtual int ExecuteCommandLine(string& line);
75 virtual int ExecuteCommand(string& keyw, vector<string>& args);
76 virtual int ExecFile(string& file);
77
78 virtual string& GetUsage(const string& kw);
79 virtual void ShowHelpWindow();
80
81 inline CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
82 inline CmdExecutor* BaseExecutor() { return(basexec); }
83 inline PIStdImgApp* GetImgApp() { return(mImgApp); }
84
85// Pour utilisation par PIAHelpWind uniquement
86 virtual void UpdateHelpList(PIAHelpWind* hw, int gid);
87
88protected:
89 virtual int CheckHelpGrp(string& grp);
90
91 NamedObjMgr* mObjMgr;
92 PIStdImgApp* mImgApp;
93
94 CmdInterpreter* curcmdi;
95 CmdExecutor* basexec;
96
97// Pour enregistrer la liste de commandes et leurs executeurs et le help
98 struct cmdex {int group; string us; CmdExecutor * cex; } ;
99 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes
100 CmdHGroup cmdhgrp;
101 int cmdgrpid; // Numero de groupe courant
102 typedef map<string, cmdex, less<string> > CmdExmap;
103 CmdExmap cmdexmap;
104 CmdExmap helpexmap; // Pour les helps sans commande
105
106// Pour garder la liste des modules
107 typedef map<string, PDynLinkMgr* , less<string> > Modmap;
108 Modmap modmap;
109
110// Pour garder la liste des interpreteur
111 typedef map<string, CmdInterpreter*, less<string> > InterpMap;
112 InterpMap interpmap;
113
114// Pour stocker les variables definies par l'interpreteur
115 typedef map<string, string, less<string> > CmdVarList;
116 CmdVarList mVars; // Liste des variables
117 ofstream hist; // History file
118 bool trace; // Trace flag
119 bool timing; // Display CPU Time
120 Timer* gltimer; // pour Display CPU Time
121
122// Fenetre d'aide interactive
123 PIAHelpWind* helpwin;
124
125};
126
127
128
129#endif
Note: See TracBrowser for help on using the repository browser.