Changeset 2463 in Sophya for trunk/SophyaPI/PIext/piacmd.h


Ignore:
Timestamp:
Nov 27, 2003, 12:01:56 AM (22 years ago)
Author:
ansari
Message:

Modification du code de PIACmd : La classe PIACmd herite maintenant de la classe Commander (de SysTools) - Reza 26/11/2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piacmd.h

    r2322 r2463  
    88
    99#include "machdefs.h"
    10 #include <iostream>
    11 #include <fstream>
     10#include "commander.h"
    1211#include <string>
    1312#include <vector>
    14 #include <list>
    15 #include <stack>
    16 #include <map>
    17 #include <functional>
    1813
    1914#include "dlftypes.h"
    20 #include "pdlmgr.h"
    21 #include "ctimer.h"
    22 
    23 // Classe definissant l'interface pour un executeur de commande
    24 class CmdExecutor {
    25 public:
    26   virtual       ~CmdExecutor() {} ;
    27   // keyw : Le mot cle associe , args: Arguments de la commande
    28   virtual int   Execute(string& keyw, vector<string>& args, string& toks)=0;
    29 };
    30 
    31 // Classe definissant l'interface pour un interpreteur de commande
    32 class CmdInterpreter {
    33 public:
    34   virtual               ~CmdInterpreter() {} ;
    35   virtual string        Name()=0;
    36   virtual int           Interpret(string& line)=0;
    37 };
    38 
    39 
    4015
    4116// Forward declaration of some classes ...
    4217class NamedObjMgr;
    4318class PIStdImgApp;
    44 #ifdef SANS_EVOLPLANCK
    45 class Timer;
    46 #else
    47 namespace SOPHYA {
    48 class Timer;
    49 }
    50 #endif
    5119
    5220class PIAHelpWind;   // Fenetre d'aide en ligne
    5321class CxxExecWind;   // Fenetre pour CxxExecutor
    5422class CxxOptionWind; // Option de CxxExecutor
    55 
    56 class PIACmdBloc;    // Bloc de type foreach / for de l'interpreteur PIACmd
    57 class PIACmdScript;  // Script de commandes defini ds l'interpreteur PIACmd
    5823
    5924// ---------------------------------------------------------------------
     
    6429
    6530
    66 class PIACmd : public CmdInterpreter  {
     31class PIACmd : public Commander  {
    6732public:
    68   static PIACmd*        GetInterpreter();
     33  //  static PIACmd*    GetInterpreter();
    6934
    7035                        PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
    7136  virtual               ~PIACmd();
    72   virtual string        Name();
    7337
    74   virtual void          RegisterCommand(string& keyw, string& usage, CmdExecutor * ce,
    75                                         string grp="Commands");
    76   virtual void          RegisterHelp(string& keyw, string& usage, string& grp);
    77   virtual void          LoadModule(string& fnameso, string& name);
    7838
    79   virtual void          AddInterpreter(CmdInterpreter * cl);
    80   virtual void          SelInterpreter(string& name);
     39  virtual int            ExecuteCommandLine(string & kw, vector<string> & tokens,
     40                                            string & toks);
     41  void                   ShowHelpWindow();
     42  void                   ShowCxxOptionWindow();
     43  void                   ShowCxxExecWindow();
    8144
    82   virtual int           Interpret(string& line);
    83   virtual int           ParseLineExecute(string& line, bool qw=true);
    84   virtual int           ExecuteCommand(string& keyw, vector<string>& args, string& toks);
    85   virtual int           ExecFile(string& file, vector<string>& args);
    86   virtual int           CShellExecute(string cmd);
    87   virtual string&       GetUsage(const string& kw);
     45    //  inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
    8846
    89           void          ShowHelpWindow();
    90           void          ShowCxxOptionWindow();
    91           void          ShowCxxExecWindow();
    92 
    93   virtual void          HelptoLaTeX(string const & flnm);
    94 
    95   inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
    9647  inline  CmdExecutor*    BaseExecutor()  { return(basexec); }
    9748  inline  CmdExecutor*    ContExecutor()  { return(cntexec); } //_OP_
     
    10152  virtual void          UpdateHelpList(PIAHelpWind* hw, int gid);
    10253
    103 //   Utilitaire pour decoupage en mot
    104   static  int   LineToWords(string& line, string& kw, vector<string>& tokens,
    105                             string& toks, bool uq=true);
    10654protected:
    10755  virtual int   CheckHelpGrp(string& grp);
    108   int           ExecuteCommandLine(string & keyw, vector<string> & args,
    109                                    string & toks);
    11056
    111   int           SubstituteVars(string & s, string & s2); 
    112   int           EvaluateTest(vector<string> & args,
    113                              string & line, bool & res);
    114   int           EvalRPNExpr(vector<string> & args, string & line);
    115 
    116   bool          GetVar(string & vn, string & vv);
    117   void          PushStack(vector<string> & args);
    118   void          PopStack(bool psta=true);
     57  virtual void  SetCurrentPrompt(const char* pr);
     58  virtual void  ShowMessage(const char * msg, int att);
    11959
    12060  NamedObjMgr* mObjMgr;
    12161  PIStdImgApp* mImgApp;
    12262
    123   CmdInterpreter* curcmdi;
    12463  CmdExecutor* basexec;  // basic command executor
    12564  CmdExecutor* fitexec;  // Fit command executor
     
    13069  CmdExecutor *flwexec; // flow chart executor _OP_
    13170 
    132 // Pour enregistrer la liste de commandes et leurs executeurs et le help
    133   struct cmdex {int group; string us; CmdExecutor * cex; } ;
    134   typedef map<string, int, less<string> > CmdHGroup;   // Liste des groupes de commandes
    135   CmdHGroup cmdhgrp;
    136   int cmdgrpid;                                     // Numero de groupe courant
    137   typedef map<string, cmdex, less<string> > CmdExmap;
    138   CmdExmap cmdexmap;
    139   CmdExmap helpexmap;                               // Pour les helps sans commande
    140 
    141 // Pour garder la liste des modules
    142   typedef map<string, PDynLinkMgr* , less<string> > Modmap;
    143   Modmap modmap;
    144 
    145 // Pour garder la liste des interpreteur
    146   typedef map<string, CmdInterpreter*, less<string> > InterpMap;
    147   InterpMap interpmap;
    148  
    149 //  Pour stocker les scripts definis ds l'interpreteur
    150   typedef map<string, PIACmdScript*, less<string> > ScriptList;
    151   ScriptList mScripts;  // Liste des scripts
    152   PIACmdScript* curscript; // Script en cours de definition
    153 
    154 //  Pour stocker les alias definies par l'interpreteur
    155   typedef map<string, string, less<string> > CmdStrList;
    156   CmdStrList mAliases;  // Liste des alias
    157 
    158 // Le stack pour les arguments des .pic et des scripts
    159   stack< vector<string> > ArgsStack;
    160 
    161   stack< PIACmdBloc * > CmdBlks;  // Bloc de commande courant (foreach, ...)
    162   int felevel;                    // foreach-for level
    163   stack< list<char> > TestsStack; // Stack des resultats de test
    164   list<char>::iterator tresit;       // Test courant
    165   bool curtestresult;             // Resultat courant des tests
    166 
    167   bool mulinefg;            // Bloc multi-lignes (ligne suite)
    168   string mulinecmd;         // Commande multi-lignes
    169   string spromptmul;        // Prompt console avant multi-ligne
    170 
    171   ofstream hist;       //  History file
    172   bool histon;        //  True ->  history file
    173   bool trace;          // Trace flag
    174   bool timing;         // Display CPU Time
    175   Timer* gltimer;      // pour Display CPU Time
    176 
    17771// Fenetre d'aide interactive
    17872  PIAHelpWind* helpwin;
Note: See TracChangeset for help on using the changeset viewer.