Changeset 333 in Sophya for trunk/SophyaPI/PIext/piacmd.cc


Ignore:
Timestamp:
Jul 12, 1999, 1:12:29 PM (26 years ago)
Author:
ercodmgr
Message:

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:
1 edited

Legend:

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

    r330 r333  
    141141usage += "  set unset listvar listcommands exec shell \n";
    142142usage += "  > set varname 'string'   # To set a variable, $varname \n";
     143usage += "  > setol varname patt     # Fills varname with object list \n";
    143144usage += "  > unset varname          # clear variable definition \n";
     145usage += "  > echo string            # output string \n";
    144146usage += "  > listvars   # List of variable names and values \n";
    145147usage += "  > listcommands # List of all known commands \n";
     
    282284int PIACmd::Interpret(string& s)
    283285{
    284 
     286int rc = 0;
    285287cmdtok tokens;
    286288if (s.length() < 1)  return(0);
     
    334336else if (kw == "set") {
    335337  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: set varname string" << endl;  return(0); }
    336   mVars[tokens[0]] = tokens[1];
     338  string xx = "";
     339  for (int kk=0; kk<tokens.size(); kk++)  xx += (tokens[kk] + ' ');
     340  mVars[tokens[0]] = xx;
     341  }
     342else if (kw == "setol") {
     343  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: setol varname objnamepattern" << endl;  return(0); }
     344  vector<string> ol;
     345  mObjMgr->GetObjList(tokens[1], ol);
     346  string vol = "";
     347  for (int kk=0; kk<ol.size(); kk++)  vol += (ol[kk] + ' ');
     348  mVars[tokens[0]] = vol;
    337349  }
    338350else if (kw == "unset") {
     
    341353  if (it != mVars.end())  mVars.erase(it);
    342354  else cerr << "PIACmd::Interpret() No variable with name " << tokens[0] << endl;
     355  }
     356else if (kw == "echo") {
     357  for (int kk=0; kk<tokens.size(); kk++)  cout << tokens[kk] << " " ;
     358  cout << endl;
    343359  }
    344360else if (kw == "listvars") {
     
    379395  }
    380396//  Execution d'une commande enregistree
    381 else {
    382   CmdExmap::iterator it = cmdexmap.find(kw);
    383   if (it == cmdexmap.end())  cout << "No such command : " << kw << " ! " << endl;
     397else rc = ExecuteCommand(kw, tokens);
     398
     399if (timing)  gltimer->Split();
     400return(rc);
     401}
     402
     403/* --Methode-- */
     404int PIACmd::ExecuteCommandLine(string& line)
     405{
     406cmdtok tokens;
     407if (line.length() < 1)  return(0);
     408
     409string toks,kw;
     410size_t p = line.find_first_not_of(" ");
     411line = line.substr(p);
     412p = 0;
     413size_t q = line.find_first_of(" ");
     414size_t l = line.length();
     415
     416if (q < l)
     417  {  kw = line.substr(p,q-p);  toks = line.substr(q, l-q); }
     418else { kw = line.substr(p,l-p);  toks = ""; }
     419
     420q = 0;
     421while (q < l)  {
     422  p = toks.find_first_not_of(" ",q+1); // au debut d'un token
     423  if (p>=l) break;
     424  q = toks.find_first_of(" ",p); // la fin du token;
     425  string token = toks.substr(p,q-p);
     426  tokens.push_back(token);
     427  }
     428
     429return(ExecuteCommand(kw, tokens)); 
     430}
     431
     432/* --Methode-- */
     433int PIACmd::ExecuteCommand(string& keyw, vector<string>& args)
     434{
     435  int rc = -1;
     436  CmdExmap::iterator it = cmdexmap.find(keyw);
     437  if (it == cmdexmap.end())  cout << "No such command : " << keyw << " ! " << endl;
    384438  else {
    385     if ((*it).second.cex) (*it).second.cex->Execute(kw, tokens);
    386     else cout << "Dont know how to execute " << kw << " ? " << endl;
     439    if ((*it).second.cex) rc = (*it).second.cex->Execute(keyw, args);
     440    else cout << "Dont know how to execute " << keyw << " ? " << endl;
    387441    }
    388   }
    389 
    390 if (timing)  gltimer->Split();
    391 return(0);
    392 }
    393 
     442  return(rc);
     443}
    394444
    395445/* --Methode-- */
Note: See TracChangeset for help on using the changeset viewer.