Changeset 2701 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Apr 27, 2005, 1:55:00 PM (20 years ago)
Author:
ansari
Message:

1/ Prise en charge de DataTable et SwPPFDataTable pour piapp (NObjMgrAdapter) :
nomhistadapter.cc et piiinit.cc
2/ Lecture de tous les objets ds un fichier PPF par NamedObjMgr::ReadAll() pour
fichier PPF sans nametag.
3/ Ajout bloc try/catch ds PIStdImgApp::Run() (boucle d'evenements)

Reza , 27 Avril 2005

Location:
trunk/SophyaPI/PIext
Files:
4 edited

Legend:

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

    r2677 r2701  
    10471047{
    10481048ZSync(*myMutex);
     1049#ifdef SANS_EVOLPLANCK
    10491050bool ok = true;
    10501051PPersist* obj=NULL;
    10511052
    10521053PInPersist* ppin=NULL;
    1053 #ifdef SANS_EVOLPLANCK
    10541054TRY{
    10551055  ppin = new PInPersist(flnm);
     
    10581058}  CATCH(merr)
    10591059  { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
    1060     (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
    1061 #else
    1062 try {
    1063   ppin = new PInPersist(flnm);
    1064   if (ppin->NbNameTags() < 1)  obj = ppin->ReadObject();
    1065   else   obj = NULL;
    1066 }
    1067 catch (IOExc iox) {
    1068     cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
    1069     ok = false;
    1070 }
    1071 #endif
     1060    (long)merr, PeidaExc(merr));  ok = false; }
     1061ENDTRY;
    10721062if (!ok)  return;
    10731063if (obj) {
     
    10771067else ReadObj((*ppin), -1);
    10781068delete ppin;
     1069#else
     1070try {
     1071  PInPersist pis(flnm);
     1072  if (pis.NbNameTags() >= 1)  {
     1073    if (pis.NbNameTags() < pis.NbTopLevelObjects()) {
     1074      cout << "NamedObjMgr::ReadAll()/Warning File " << flnm << " NbNameTags="
     1075           << pis.NbNameTags() << " < NbTopLevelObjects= "
     1076           << pis.NbTopLevelObjects() << endl;
     1077      cout << " ... Reading " << pis.NbNameTags() << " objects at NameTags " ;
     1078    }
     1079    ReadObj(pis, -1);
     1080    return;
     1081  }
     1082
     1083  string nom = servnobjm->FileName2Name(flnm); 
     1084  int kn = 1;
     1085  for(int ii=0; ii<pis.NbTopLevelObjects(); ii++) {
     1086    PPersist* obj = pis.ReadObject();
     1087    if (!obj) continue;
     1088    AddObj_P(obj->DataObj(), nom, false);
     1089    kn++;
     1090    nom += (string)MuTyV(kn);
     1091  }
     1092}
     1093catch (IOExc& iox) {
     1094  cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
     1095}
     1096#endif
    10791097return;
    10801098}
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r2697 r2701  
    1818// Pour les DataTable ( Depuis Avril 2005 )
    1919#include "datatable.h"
     20#include "swppfdtable.h"
    2021#endif
    2122
     
    620621  DataTable* dt = dynamic_cast<DataTable *>(mDT);
    621622  if (dt) return ("DataTable ");
    622   else return  ("BaseDataTable ");
     623  else {
     624    SwPPFDataTable* swdt = dynamic_cast<SwPPFDataTable *>(mDT);
     625    if (swdt) return ("SwPPFDataTable ");
     626    return  ("BaseDataTable ");
     627  }
    623628}
    624629
     
    628633  DataTable* dt = dynamic_cast<DataTable *>(mDT);
    629634  if (dt) return new DataTable(*dt, share);
    630   else return NULL;
     635  else {
     636    SwPPFDataTable* swdt = dynamic_cast<SwPPFDataTable *>(mDT);
     637    if (swdt) cout << "NOMAdapter_DataTable::CloneDataObj() Object type SwPPFDataTable can not be cloned !" << endl;
     638    return NULL;
     639  }
    631640}
    632641
     
    647656{
    648657  DataTable* dt = dynamic_cast<DataTable *>(mDT);
    649   if (dt) {
    650     ObjFileIO<DataTable> fio(dt);
     658  SwPPFDataTable* swdt = dynamic_cast<SwPPFDataTable *>(mDT);
     659  if (dt) {     
     660    ObjFileIO<BaseDataTable> fio(dt);
    651661    fio.Write(pos, nom);
    652662  }
     663  else if (swdt) {
     664    ObjFileIO<BaseDataTable> fio(swdt);
     665    fio.Write(pos, nom);
     666  }             
    653667  else {
    654     cerr << " NOMAdapter_DataTable::SavePPF() Objet pas de type DataTable (nom="
     668    cerr << " NOMAdapter_DataTable::SavePPF() Objet pas de type DataTable/SwPPFDataTable (nom="
    655669         << nom << ")" << endl;
    656670  }
  • trunk/SophyaPI/PIext/piinit.cc

    r2697 r2701  
    1818
    1919#include "datatable.h"
     20#include "swppfdtable.h"
    2021
    2122#include "nomskymapadapter.h"
     
    5253
    5354  serv->RegisterClass(new DataTable, new NOMAdapter_DataTable );
     55  serv->RegisterClass(new SwPPFDataTable, new NOMAdapter_DataTable );
    5456  char* varenv=NULL;
    5557  if ( (varenv=getenv("PEIDA_TMP")) == NULL )   varenv=getenv("TMPDIR") ;
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2677 r2701  
    455455  fg_glsynlock = true;
    456456  int nevtproc = 0;
    457   while (XtAppPending(*appctx) != 0) {
    458     XtAppNextEvent(*appctx, &evt);
    459     XtDispatchEvent(&evt);
    460 // Soumission de la commande exterieur a executer
    461     if (fg_exc_cmd) {
    462       fg_exc_cmd = false;
    463       CmdInterpreter()->AddInputLine(exc_command);
     457  while (XtAppPending(*appctx) != 0) {   // Boucle XtAppPending()
     458    try {
     459      XtAppNextEvent(*appctx, &evt);
     460      XtDispatchEvent(&evt);
     461      // Soumission de la commande exterieur a executer
     462      if (fg_exc_cmd) {
     463        fg_exc_cmd = false;
     464        CmdInterpreter()->AddInputLine(exc_command);
     465      }
     466      nevtproc++;
     467      if (nevtproc >= 200)  break;
    464468    }
    465     nevtproc++;
    466     if (nevtproc >= 200)  break;
    467   }
     469    catch ( PThrowable & exc ) {
     470      cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   "
     471           << (string)typeid(exc).name() << " Msg= " << exc.Msg() << endl;
     472      cerr << "  Trying to continue event loop ... " << endl;
     473    }
     474    catch ( std::exception & sexc ) {
     475      cerr << "\nPIStdImgApp::Run()/ Exception catched in event loop: \n   "
     476           << (string)typeid(sexc).name() << " what()= " << sexc.what() << endl;
     477      cerr << "  Trying to continue event loop ... " << endl;
     478    }
     479    catch ( ... ) {
     480      cerr << "\nPIStdImgApp::Run()/ Unknown Exception (...) catched in event loop ! " << endl;
     481      cerr << "  Trying to continue event loop ... " << endl;
     482    }
     483  }   // FIN Boucle XtAppPending()
    468484  fg_glsynlock = false;
    469485  //DBG cout << " "DBG-Run:: Going to wait ... " << klp << endl;
Note: See TracChangeset for help on using the changeset viewer.