Changeset 2287 in Sophya


Ignore:
Timestamp:
Dec 5, 2002, 12:16:52 PM (23 years ago)
Author:
ansari
Message:

modifs cxxexecutor avec options declarevars + echo2file - Reza 5/12/02

Location:
trunk/SophyaPI/PIext
Files:
3 edited

Legend:

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

    r2182 r2287  
    1515  : mUserCodeFn(""), mUserFctFn("")
    1616  , mCompOpt(""), mLinkOpt(""), mMyLibs("")
    17   , mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(2)
     17  , mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(2), mFgPutVar(false)
    1818{
    1919mIncList.resize(0);
     
    121121usage+= "       c++import -?? : list of available modules for executor\n";
    122122usage+= "Warning: to be used before c++create c++compile c++exec ...";
     123mpiac->RegisterCommand(kw, usage, this, hgrp);
     124
     125kw = "c++declareomgvar";
     126usage = "c++declareomgvar: Activate/Deactivate ObjectManager variables declaration \n";
     127usage+= "Usage: c++declareomgvar [false/true] \n";
     128usage+= "   if true, the ObjectManager variables are declared as $varname \n";
     129usage+= "   no arguments: display the current status of the flag (default=false\n";
    123130mpiac->RegisterCommand(kw, usage, this, hgrp);
    124131
     
    234241  }
    235242  FillModuleImport(tokens);
    236 
     243} else if(kw == "c++declareomgvar") {
     244  if (tokens.size() <1) {
     245    string fgstat = (mFgPutVar) ? "TRUE" : "FALSE" ;
     246    cout << " c++declareomgvar: Current flag status: " <<  fgstat << endl;
     247  }
     248  else {
     249    if (tokens[0] == "true") DeclareObjMgrVar(true);
     250    else  if (tokens[0] == "false") DeclareObjMgrVar(false);
     251  }
    237252} else if(kw == "c++prtlevel") {
    238253  if(tokens.size()==1) if(tokens[0]=="-?")
     
    300315os<<endl;
    301316
    302 PutVar(os);
     317if (mFgPutVar) PutVar(os);
    303318os<<endl;
    304319
     
    388403  <<"  om.DisplayObj(name, opt); \n"
    389404  <<"} \n" << endl;
    390 
    391 os<<"//---- Objects and variables saving"<<endl
    392   <<"#define KeepObj(obj) Keep_Object(obj, #obj);"<<endl
    393   <<"#define KeepVar(var) ___nomobj = #var; omg.GetVarList().Get(___nomobj) = var ;"<<endl
     405os<<"//---- function for getting and setting ObjectManager variables  " << endl;
     406os<<"void Set_ObjMgrVar(MuTyV v, string const & nom) \n{ \n"
     407  <<"  NamedObjMgr om; \n"
     408  <<"  om.SetVar(nom, (string)v); \n"
     409  <<"} \n" << endl;
     410os<<"MuTyV Get_ObjMgrVar(const char * nom) \n{ \n"
     411  <<"  string name = nom; NamedObjMgr om; \n"
     412  <<"  MuTyV v = om.GetVar(name); \n"
     413  <<"  return v; \n"
     414  <<"} \n" << endl;
     415
     416os<<"//---- Macro for Objects and variables saving"<<endl
     417  <<"#define KeepObj(obj) Keep_Object(obj, #obj)"<<endl
     418  <<"#define GetOMVar(var) Get_ObjMgrVar( #var )"<<endl
     419  <<"#define SetOMVar(var) Set_ObjMgrVar(var, #var )"<<endl
    394420  <<endl;
    395421
    396 os<<"//---- Displaying objects and command execution"<<endl;
     422os<<"//---- Macro Displaying objects and command execution"<<endl;
    397423os<<"#define DisplayObj(obj, att) Display_Object(obj, att, #obj); \n" << endl;
    398424os<<"#define ExecuteCommand(cmd) srvo.ExecuteCommand(cmd); \n" << endl;
  • trunk/SophyaPI/PIext/cxxexecutor.h

    r2181 r2287  
    2828
    2929  int  ExecuteCXX(string usercode,string userfct="");
     30
     31  // if true , declare ObjMgr variables as $varname
     32  inline void DeclareObjMgrVar(bool fg=false) { mFgPutVar=fg; }
    3033
    3134  int  CrFile(string cfilename="",string func="");
     
    9295
    9396  uint_2 mPrtLevel;
     97  bool   mFgPutVar;  // if true , declare ObjMgr variables as $varname, default=false
    9498};
    9599
  • trunk/SophyaPI/PIext/piacmd.cc

    r2285 r2287  
    431431usage += "  > rpneval varname RPNExpression # Reverse Polish Notation evaluation \n";
    432432usage += "  > echo string            # output string \n";
     433usage += "  > echo2file filename string # Append the string to the specified file \n";
    433434usage += "  > alias name string      # define a command alias \n";
    434435usage += "  > readstdin varname      # reads a line from stdin into $varname \n";
     
    15281529  cout << endl;
    15291530 }
     1531else if (kw == "echo2file") {
     1532  if (tokens.size() < 1) {
     1533    cout << "PIACmd::Interpret() Usage: echo2file filename [string ] " << endl; 
     1534    return(0);
     1535  }
     1536  ofstream ofs(tokens[0].c_str(), ios::app);
     1537  for (int ii=1; ii<tokens.size(); ii++)
     1538    ofs << tokens[ii] << " " ;
     1539  ofs << endl;
     1540 }
    15301541else if (kw == "readstdin") {
    15311542  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: readstdin varname" << endl;  return(0); }
Note: See TracChangeset for help on using the changeset viewer.