Changeset 1237 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Oct 18, 2000, 8:12:00 PM (25 years ago)
Author:
ercodmgr
Message:
  • DataType -> DataTypeInfo
  • modifs cxxexecutor pour

nom de variable: var -> $var
pour #include "cxx_spiapp.h"

cmv 18/10/00

Location:
trunk/SophyaPI/PIext
Files:
5 edited

Legend:

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

    r1233 r1237  
    33#include <typeinfo>
    44
     5#include "strutilxx.h"
    56#include "dvlist.h"
    67
     
    910
    1011
    11 void FillVStringFrString(string s,vector<string>& vs,char sep = ' ');
    12 
    13 
    1412/* --Methode-- */
    1513CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
    16   : mCompOpt(""), mLinkOpt(""), mMyLibs("")
    17 {
    18 mUserCode.resize(0);
     14  : mUserCodeFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("")
     15{
    1916mIncList.resize(0);
    2017mCallArgs.resize(0);
    21 
    22 NamedObjMgr omg;
    2318
    2419// On enregistre les nouvelles commandes
     
    2823kw = "c++exec";
    2924usage = "c++exec: Execute the following c++ user code\n";
    30 usage+= "Usage: c++exec c++ user code";
     25usage+= "Usage: c++exec c++ user code\n";
     26usage+= "Warning: c++ user code can be found in \"cxx_spiapp.h\"\n";
     27usage+= "         total generated code can be found in \"cxx_spiapp.cc\"";
    3128mpiac->RegisterCommand(kw, usage, this, hgrp);
    3229
    3330kw = "c++execfrf";
    3431usage = "c++execfrf: Execute c++ user code contained in a file\n";
    35 usage+= "Usage: c++execfrf fileuser.cc";
     32usage+= "Usage: c++execfrf fileuser.cc\n";
     33usage+= "Warning: total generated code can be found in \"cxx_spiapp.cc\"";
    3634mpiac->RegisterCommand(kw, usage, this, hgrp);
    3735
    3836kw = "c++args";
    39 usage = "c++args: Define user function arguments\n";
     37usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
    4038usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
    4139usage+= "       c++args -? : give current arguments\n";
     
    10098
    10199
     100//// A VIRER quand variable de objmanager OK  --> Pour Reza
    102101kw = "c++setvar";
    103102usage = "c++setvar: Setting test variable \n";
     
    114113usage+= "c++varlist  ";
    115114mpiac->RegisterCommand(kw, usage, this, hgrp);
     115//// A VIRER quand variable de objmanager OK  --> Pour Reza
    116116
    117117}
     
    193193
    194194
    195 
     195//// A VIRER quand variable de objmanager OK  --> Pour Reza
    196196} else if(kw == "c++setvar") {
    197197  if(tokens.size()<2) {
     
    215215  cout<<omg.GetVarList();
    216216}
     217//// A VIRER quand variable de objmanager OK  --> Pour Reza
    217218
    218219
     
    224225{
    225226ofstream os(cfilename.c_str(),ios::out);
    226 if(!os) {
    227   cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
    228   return 1;
    229 }
     227if(!os)
     228  {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
     229   return 1;}
    230230
    231231PutInclude(os);
     
    243243os<<"NamedObjMgr omg;"<<endl;
    244244os<<"Services2NObjMgr& srvo = *omg.GetServiceObj();"<<endl;
    245 os<<"//omg.AddObj(OBJECT* object,string nom_object);"<<endl;
    246245os<<endl;
    247246
     
    252251os<<endl;
    253252
    254 PutUserCode(os);
    255 os<<endl;
    256 
    257 os<<endl;
     253os<<"//--------------------------------------------//"<<endl;
     254os<<"//------------- Code utilisateur -------------//"<<endl;
     255os<<"//--------------------------------------------//"<<endl;
     256os<<endl;
     257os<<"#include \""<<mUserCodeFn<<"\""<<endl;
     258os<<endl;
     259
    258260os<<"return 0;"<<endl;
    259261os<<"}"<<endl;
    260262
    261263cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl;
     264cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl;
    262265return 0;
    263266}
     
    360363  string key = (*it).first;
    361364  os<<"___nomobj = \""<<key<<"\";"<<endl;
    362   os<<"MuTyV & "<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
    363 }
    364 
    365 }
    366 
    367 /* --Methode-- */
    368 void CxxExecutor::PutUserCode(ofstream& os)
    369 {
    370 os<<"//--------------------------------------------//"<<endl;
    371 os<<"//------------- Code utilisateur -------------//"<<endl;
    372 os<<"//--------------------------------------------//"<<endl;
    373 os<<endl;
    374 if(mUserCode.size()<1) return;
    375 for(uint_4 i=0;i<mUserCode.size();i++) os<<mUserCode[i]<<endl;
     365  os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
     366}
     367
     368return;
    376369}
    377370
     
    379372int CxxExecutor::FillUserCode(vector<string>& usercode,uint_4 first)
    380373// - first is the first position in the vector<> where the code starts
    381 {
    382 mUserCode.resize(0);
     374// User code is read from input. It is put into file "cxx_spiapp.h".
     375{
     376mUserCodeFn = "";
    383377uint_4 nus = usercode.size();
    384 if(nus<=first) {
    385   cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
    386   return 1;
    387 }
    388 string dum = "";
     378if(nus<=first) {cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
     379                return 1;}
     380mUserCodeFn = "cxx_spiapp.h";
     381ofstream os(mUserCodeFn.c_str(),ios::out);
     382if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
     383             <<mUserCodeFn<<endl;  mUserCodeFn = ""; return 1;}
    389384// On ajoute un blanc pour les chaines de caracteres contenant des blancs
    390 for(uint_4 i=first;i<nus;i++) dum += " " + usercode[i];
    391 // Tout dans une seule ligne pour eviter les pbs (cf au bas du fichier)
    392 mUserCode.push_back(dum);
    393 cout<<"User code filled from standard input"<<endl;
     385for(uint_4 i=first;i<nus;i++) os<<" "<<usercode[i];
     386os<<endl;
     387cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
    394388return 0;
    395389}
     
    397391/* --Methode-- */
    398392int CxxExecutor::FillUserCode(string filename)
    399 {
    400 mUserCode.resize(0);
    401 
    402 ifstream is(filename.c_str());
    403 if(!is) {
    404   cout<<"CxxExecutor::FillUserCode: unable to open "<<filename<<endl;
    405   return 1;
    406 }
    407 
    408 int nline = 4096; // Au plus 4096 characters par ligne!
    409 char *str = new char[nline+2];
    410 while(is)
    411   {is.getline(str,nline); mUserCode.push_back((string) str);}
    412 delete [] str;
    413 if(mUserCode.size()<=0) {
    414   return 2;
    415   cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
    416 }
    417 
     393// User code is read from "filename".
     394{
     395mUserCodeFn = filename;
    418396cout<<"User code filled from file "<<filename<<endl;
    419397return 0;
     
    501479vector<string> arg; arg.push_back(func);
    502480if(mCallArgs.size()>0)
    503   for(int i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
     481  for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
    504482mpiac->ExecuteCommand(key,arg);
    505483return 0;
     
    609587/* --Methode--  DO NOT DELETE.... cmv property !!!
    610588int CxxExecutor::FillUserCode(vector<string>& usercode,uint_4 first)
    611 // - first is the first position in the vector<> where the code starts
    612 {
    613 mUserCode.resize(0);
     589{
     590mUserCodeFn = "";
    614591uint_4 nus = usercode.size();
    615592if(nus<=first) {
     
    617594  return 1;
    618595}
     596mUserCodeFn = "cxx_spiapp.h";
     597ofstream os(mUserCodeFn.c_str(),ios::out);
     598if(!os)
     599  {cout<<"CxxExecutor::FillUserCode: unable to open "<<mUserCodeFn<<endl;
     600   mUserCodeFn = ""; return 1;}
    619601// **** 1er probleme ****
    620602// - Pour la lisibilite et eviter les bugs avec les chaines de caracteres
     
    653635    //                                2-/ c'est le dernier charactere
    654636    if((str[j]==';' && !comment) || lastchar)
    655       {mUserCode.push_back(dum); dum = "";}
     637      {os<<dum<<endl; dum = "";}
    656638  }
    657639}
    658 cout<<"User code filled from standard input"<<endl;
     640cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
    659641return 0;
    660642}
    661643*/
    662 
    663 
    664 void FillVStringFrString(string s,vector<string>& vs,char sep)
    665 // Use string "s" to fill vector of strings "vs"
    666 // considering char "sep" as a separator.
    667 // Vector is filled from its end (no reset done).
    668 // Tp write a "sep" char, use \'sep'
    669 // Warning: separator "sep" could not be set to '\'
    670 // Ex: sep=' ': s="aaa   bbb cc d " -> vs=(aaa,bbb,cc,d)
    671 // Ex: sep=';': s="aaa   ;bbb; cc;d " -> vs=(aaa   ,bbb, cc,d )
    672 // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd" -> vs=(aaa;bbb,ccc,ddd)
    673 // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd\" -> vs=(aaa;bbb,ccc,ddd\)
    674 {
    675 uint_4 ls = s.size();
    676 if(ls<=0 || sep=='\\') return;
    677 s += sep; // add a separator at the end
    678 const char* str = s.c_str();
    679 ls = strlen(str); // str[ls-1]==sep cf ci-dessus
    680 string dum = "";
    681 for(uint_4 i=0; i<ls; i++) {
    682   if(i==0 && str[i]==sep) {
    683     continue;
    684   } else if(str[i]=='\\') {
    685     if(str[i+1]!=sep || i==ls-2) dum += str[i];
    686   } else if(str[i]!=sep) {
    687     dum += str[i];
    688   } else {  // C'est un "sep" mais est-ce vraiment un separateur?
    689     if(str[i-1]=='\\' && i!=ls-1) dum += str[i];
    690     else {  // C'est un separateur, ne delimite t-il pas d'autres separateurs?
    691       if(dum.size()<=0) continue;
    692       vs.push_back(dum);
    693       dum = "";
    694     }
    695   }
    696 }
    697 }
  • trunk/SophyaPI/PIext/cxxexecutor.h

    r1230 r1237  
    11// This may look like C code, but it is really -*- C++ -*-
    2 // Classe CxxExecutor  : Dynmamic C++ compile/execution in piapp
     2// Classe CxxExecutor  : Dynamic C++ compile/execution in piapp
    33// (c) DAPNIA (CEA)                 LAL (IN2P3/CNRS)
    44//                           C. Magneville  10/2000
     
    3030       void PutObject(ofstream& os);
    3131       void PutVar(ofstream& os);
    32        void PutUserCode(ofstream& os);
    3332
    3433  int  FillUserCode(vector<string>& usercode,uint_4 first);
     
    6261
    6362private:
     63  string mUserCodeFn;
    6464  string mCompOpt;
    6565  string mLinkOpt;
    6666  string mMyLibs;
    67   vector<string> mUserCode;
    6867  vector<string> mIncList;
    6968  vector<string> mCallArgs;
  • trunk/SophyaPI/PIext/nomimagadapter.cc

    r1224 r1237  
    5252string type = "Image< ";
    5353// type +=  DecodeTypeIdName(typeid(T).name());
    54 type += DataType<T>::getTypeName();
     54type += DataTypeInfo<T>::getTypeName();
    5555type +=  " > ";
    5656return(type);
  • trunk/SophyaPI/PIext/nomskymapadapter.cc

    r1224 r1237  
    8888
    8989// type +=  DecodeTypeIdName(typeid(T).name());
    90 type += DataType<T>::getTypeName();
     90type += DataTypeInfo<T>::getTypeName();
    9191type +=  " > ";
    9292return(type);
  • trunk/SophyaPI/PIext/nomtmatvecadapter.cc

    r1224 r1237  
    5656
    5757// type +=  DecodeTypeIdName(typeid(T).name());
    58 type += DataType<T>::getTypeName();
     58type += DataTypeInfo<T>::getTypeName();
    5959type +=  " > ";
    6060return(type);
Note: See TracChangeset for help on using the changeset viewer.