| 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 "commander.h"
 | 
|---|
| 11 | #include <string>
 | 
|---|
| 12 | #include <vector>
 | 
|---|
| 13 | #include <queue>
 | 
|---|
| 14 | #include "zthread.h"
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include "dlftypes.h"
 | 
|---|
| 17 | 
 | 
|---|
| 18 | // Forward declaration of some classes ...
 | 
|---|
| 19 | class NamedObjMgr;
 | 
|---|
| 20 | class PIStdImgApp;
 | 
|---|
| 21 | 
 | 
|---|
| 22 | class PIAHelpWind;   // Fenetre d'aide en ligne 
 | 
|---|
| 23 | class CxxExecWind;   // Fenetre pour CxxExecutor
 | 
|---|
| 24 | class CxxOptionWind; // Option de CxxExecutor
 | 
|---|
| 25 | 
 | 
|---|
| 26 | // ---------------------------------------------------------------------
 | 
|---|
| 27 | // Classe Interpreteur de commande, gestionnaire de module chargeable,
 | 
|---|
| 28 | // et de fonctions dynamiquement linke pour PIStdImgApp
 | 
|---|
| 29 | // Permet de gerer plusieurs Interpreter differents 
 | 
|---|
| 30 | // ---------------------------------------------------------------------
 | 
|---|
| 31 | 
 | 
|---|
| 32 | 
 | 
|---|
| 33 | class PIACmd : public Commander, public ZThread  {
 | 
|---|
| 34 | public:
 | 
|---|
| 35 |   //  static PIACmd*    GetInterpreter();
 | 
|---|
| 36 | 
 | 
|---|
| 37 |                         PIACmd(PIStdImgApp* app);
 | 
|---|
| 38 |   virtual               ~PIACmd();
 | 
|---|
| 39 | 
 | 
|---|
| 40 |   // Thread execution  <ZThread>
 | 
|---|
| 41 |   virtual void          run();
 | 
|---|
| 42 |   void                  AddInputLine(string const & line);
 | 
|---|
| 43 |   void                  StopThread();
 | 
|---|
| 44 |   inline  bool          isRunning(int& ninp) 
 | 
|---|
| 45 |     { ninp = inputlines.size(); return fg_threxe; }
 | 
|---|
| 46 |   // ---- FIN ---- Thread execution  <ZThread>
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   void                   ShowHelpWindow();
 | 
|---|
| 49 |   void                   ShowCxxOptionWindow();
 | 
|---|
| 50 |   void                   ShowCxxExecWindow();
 | 
|---|
| 51 | 
 | 
|---|
| 52 |     //  inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   inline  CmdExecutor*   BaseExecutor()  { return(basexec); }
 | 
|---|
| 55 |   inline  CmdExecutor*   ContExecutor()  { return(cntexec); } //_OP_
 | 
|---|
| 56 |   inline  PIStdImgApp*   GetImgApp() { return(mImgApp); }
 | 
|---|
| 57 | 
 | 
|---|
| 58 | //   Pour utilisation par PIAHelpWind uniquement 
 | 
|---|
| 59 |   virtual void          UpdateHelpList(PIAHelpWind* hw, int gid);
 | 
|---|
| 60 | 
 | 
|---|
| 61 | // Acces aux objets transforme en string 
 | 
|---|
| 62 |   virtual bool    GetVarApp(string const & vn, string & vv);
 | 
|---|
| 63 | 
 | 
|---|
| 64 | protected:
 | 
|---|
| 65 |   virtual int   ExecuteCommandLine(string & kw, vector<string> & tokens, 
 | 
|---|
| 66 |                                    string & toks);
 | 
|---|
| 67 | 
 | 
|---|
| 68 |   virtual bool  CheckHelpGrp(string& grp, int& gid, string& desc);
 | 
|---|
| 69 |   virtual void  InitializeHelpWindowMenu();
 | 
|---|
| 70 | 
 | 
|---|
| 71 |   virtual void  SetCurrentPrompt(const char* pr);
 | 
|---|
| 72 |   virtual void  ShowMessage(const char * msg, int att);
 | 
|---|
| 73 | 
 | 
|---|
| 74 |   NamedObjMgr* mObjMgr;
 | 
|---|
| 75 |   PIStdImgApp* mImgApp;
 | 
|---|
| 76 | 
 | 
|---|
| 77 |   CmdExecutor* basexec;  // base command executor
 | 
|---|
| 78 |   CmdExecutor* graphexec; // graphic command executor
 | 
|---|
| 79 |   CmdExecutor* fitexec;  // Fit command executor
 | 
|---|
| 80 |   CmdExecutor* pawexec;  // paw-like command executor
 | 
|---|
| 81 |   CmdExecutor* cxxexec;  // on-line c++ compile/execution command executor
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   CmdExecutor *cntexec; // contour executor _OP_
 | 
|---|
| 84 |   CmdExecutor *flwexec; // flow chart executor _OP_
 | 
|---|
| 85 |  
 | 
|---|
| 86 | // Fenetre d'aide interactive 
 | 
|---|
| 87 |   PIAHelpWind* helpwin;
 | 
|---|
| 88 |   bool helpwin_initdone;
 | 
|---|
| 89 | // Fenetres d'execution interactive de C++ , options correspondantes
 | 
|---|
| 90 |   CxxExecWind* cxxexwin;
 | 
|---|
| 91 |   CxxOptionWind* cxxoptwin;
 | 
|---|
| 92 | 
 | 
|---|
| 93 | // Queue des entrees et controle de thread
 | 
|---|
| 94 |   queue<string> inputlines;
 | 
|---|
| 95 |   bool fg_thrstop;
 | 
|---|
| 96 |   ZMutex mutx_inps;
 | 
|---|
| 97 |   bool fg_threxe;
 | 
|---|
| 98 | 
 | 
|---|
| 99 | };
 | 
|---|
| 100 | 
 | 
|---|
| 101 | 
 | 
|---|
| 102 | // 
 | 
|---|
| 103 | // ---------------------------------------------------------------------
 | 
|---|
| 104 | // Classe d'execution d'operations simples, comme affichage (display)
 | 
|---|
| 105 | // print , del ... issues en particulier de la boucle d'evts 
 | 
|---|
| 106 | // (PIStdImgApp, ObjMgrWind , ...)
 | 
|---|
| 107 | // ---------------------------------------------------------------------
 | 
|---|
| 108 | 
 | 
|---|
| 109 | class SOpExObj : public ZThread  {
 | 
|---|
| 110 | public:
 | 
|---|
| 111 |                         SOpExObj(PIStdImgApp* app);
 | 
|---|
| 112 |   virtual               ~SOpExObj();
 | 
|---|
| 113 | 
 | 
|---|
| 114 |   // Thread execution  <ZThread>
 | 
|---|
| 115 |   virtual void          run();
 | 
|---|
| 116 |   void                  AddOpe(string const & line);
 | 
|---|
| 117 |   void                  StopThread();
 | 
|---|
| 118 | 
 | 
|---|
| 119 | protected:
 | 
|---|
| 120 |   PIStdImgApp* mImgApp;
 | 
|---|
| 121 |   queue<string> inputlines;
 | 
|---|
| 122 |   ZMutex mutx_inps;
 | 
|---|
| 123 |   bool fg_thrstop;
 | 
|---|
| 124 |   bool fg_threxe;
 | 
|---|
| 125 | };
 | 
|---|
| 126 | 
 | 
|---|
| 127 | 
 | 
|---|
| 128 | 
 | 
|---|
| 129 | 
 | 
|---|
| 130 | #endif
 | 
|---|