source: Sophya/trunk/SophyaPI/PIext/nobjmgr.cc@ 2757

Last change on this file since 2757 was 2757, checked in by ansari, 20 years ago

Suite corrections (PAS FINI / voir ObjMgrWind et UpdateObjMgrWindow() ) des synchronisations entre threads - Reza 24/5/2005

File size: 47.0 KB
RevLine 
[165]1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4
[295]5#include <typeinfo>
[2322]6#include <iostream>
[165]7#include <string>
8#include <list>
9#include <map>
10
[2615]11#include "sopnamsp.h"
[165]12#include "strutil.h"
13#include "datatypes.h"
14
15#include "nobjmgr.h"
16#include "servnobjm.h"
[330]17#include "nomgadapter.h"
[165]18#include "pistdimgapp.h"
19
[1164]20#include "dvlist.h"
[165]21
[293]22// EVOL-PLANCK
23#ifdef SANS_EVOLPLANCK
24#include "fitsimage.h"
[1321]25#else
26#include "fitsautoreader.h"
[1525]27#include "tvector.h"
28#include "pitvmaad.h"
[1905]29#include "piyfxdrw.h"
[293]30#endif
31
[295]32#include "pisurfdr.h"
[165]33#include "pipodrw.h"
[333]34
[165]35#include "pintuple.h"
36#include "pintup3d.h"
37#include "pigfd1.h"
38#include "pigfd2.h"
39
[2491]40#include "zthread.h"
[165]41
[2491]42
[165]43//++
44// Class NamedObjMgr
45// Lib PI
46// include nobjmgr.h
47//
[344]48// Cette classe fournit les services nécéssaires à la gestion des objets
[165]49// (l'ensemble des objets PPersist de PEIDA++) au sein du programme
50// d'analyse interactive *piapp* . Elle constitue en outre l'interface
51// entre les fonctions utilisateur et l'application graphique.
52//--
53//++
54// Links Voir aussi
55// PIStdImgApp
56// Services2NObjMgr
57// PIACmd
58//--
59
60
61// ..................................................................
62// ...... Gestion des objets nommes, variables globales ............
[331]63struct nobj_diritem {
[344]64 int id; // Directory Id
65 int nobj; // Number of objects in directory
66 bool lock; // True -> directory locked, No Add, del or rename
67 bool keepold; // True -> When duplicate object name, old object moved to /old
[331]68};
69
70typedef map<string, nobj_diritem, less<string> > NObjDirList;
71
[165]72struct nobj_item {
[344]73 AnyDataObj* obj; // Object pointer
74 NObjMgrAdapter* obja; // Object adapter pointer
75 int oid; // object Id
76 int dirid; // Directory Id
77 list<int> wrsid; // List of Window Resource Id (Drawer, PIBaseWdg, ...)
78 // (for PIStdImgApp)
[165]79 bool operator==(nobj_item const& b) const
80 { return (this->obj == b.obj); }
81};
82
83typedef map<string, nobj_item, less<string> > NObjList;
84
[331]85static NObjDirList* myDirs = NULL;
86static NObjList* myObjs = NULL;
[165]87static int fgOInit = 0;
88static int myNObj = 0;
[331]89static int myDirId = 0;
90static string* currDir;
[165]91
92static PIStdImgApp* myImgApp=NULL;
93static Services2NObjMgr* servnobjm=NULL;
94
[1164]95static DVList* myVars = NULL; // Pour stocker les variables
96
[2755]97static string* TmpDir = NULL; // Repertoire pour les compilations / link dynamique
[165]98
[2491]99// Pour gestion multithread
[2755]100static ZMutex* myMutex = NULL;
[333]101// ..................................................................
102
[165]103//++
104// Titre Constructeurs
105//--
106//++
107// NamedObjMgr()
108// Constructeur. Les différents instantiation de la classe "NamedObjMgr"
109// dans une même application créent des objets qui travaillent sur la même
110// liste d'objets. Les objets de cette classe ne possedent en effet pas
111// de variables membres.
112//--
113
114/* --Methode-- */
[2490]115NamedObjMgr::NamedObjMgr(bool fgimgapp)
[165]116{
[2490]117_fgimgapp = fgimgapp;
[165]118if (fgOInit == 0) {
[333]119 myNObj = 0;
120 myDirId = 0;
[331]121 myDirs = new NObjDirList;
[165]122 myObjs = new NObjList;
[1164]123 myVars = new DVList;
[2755]124 myMutex = new ZMutex;
[331]125 currDir = new string("home");
[333]126 string dirn = "home";
[2491]127 CreateDir_P(dirn);
[2132]128 SetKeepOldDirAtt(dirn, false);
[333]129 dirn = "tmp";
[2491]130 CreateDir_P(dirn);
[344]131 SetKeepOldDirAtt(dirn, false);
[466]132 dirn = "autoc";
[2491]133 CreateDir_P(dirn);
[368]134 SetKeepOldDirAtt(dirn, false);
[333]135 dirn = "old";
[2491]136 CreateDir_P(dirn);
[344]137 SetKeepOldDirAtt(dirn, false);
[333]138 dirn = "home";
139 SetCurrentDir(dirn);
140 myDirId = 50;
[165]141 char* varenv;
142 TmpDir = new string("");
[1276]143 if ( (varenv=getenv("TMPDIR")) != NULL ) (*TmpDir) = varenv;
[165]144 int l = (*TmpDir).length();
145 if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
[2491]146 servnobjm = new Services2NObjMgr(*TmpDir);
[165]147 }
148fgOInit++;
149}
150
151
152/* --Methode-- */
153NamedObjMgr::~NamedObjMgr()
154{
155fgOInit--;
[1164]156if (fgOInit == 0) {
157 string patt = "/*/*";
158 DelObjects(patt, true);
159 delete myObjs;
160 delete myDirs;
161 delete myVars;
[2491]162 delete myMutex;
[165]163}
[1164]164}
[165]165
166//++
167// Titre Méthodes
168//--
169//++
170// void SetImgApp(PIStdImgApp* app)
171// Spécifie l'objet "PIStdImgApp" associé.
172// PIStdImgApp* GetImgApp()
173// Accès à l'objet "PIStdImgApp" associé.
174//--
175
176/* --Methode-- */
177void NamedObjMgr::SetImgApp(PIStdImgApp* app)
178{
179myImgApp = app;
180servnobjm->SetImgApp(app);
[333]181
182NObjDirList::iterator it;
183string cn;
184for(it= myDirs->begin(); it != myDirs->end(); it++) {
185 cn = '/' + (*it).first;
186 (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
187 }
[165]188}
189
[449]190
191static bool verbeux = false; // true -> plus de message (creation/suppression d'objets)
192void NamedObjMgr::SetVerbose(bool fg)
193{
194verbeux = fg;
195}
196
[165]197/* --Methode-- */
198PIStdImgApp* NamedObjMgr::GetImgApp()
199{
200return(myImgApp);
201}
202
203/* --Methode-- */
204Services2NObjMgr* NamedObjMgr::GetServiceObj()
205{
206return(servnobjm);
207}
208
[331]209/* --Methode-- */
[1268]210string const& NamedObjMgr::GetTmpDir()
[1265]211{
212return *TmpDir;
213}
214
215/* --Methode-- */
[1268]216void NamedObjMgr::SetTmpDir(string const& tmpdir)
[1265]217{
218if(tmpdir.length()<1) return;
219*TmpDir = tmpdir;
[1276]220int l = (*TmpDir).length();
221if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
222servnobjm->SetTmpDir(*TmpDir);
[1265]223}
224
225/* --Methode-- */
[1164]226bool NamedObjMgr::SetVar(string const & key, string const & val)
227{
[2218]228 if ((key.length() < 1) || (! isalpha(key[0])) ) {
229 cout << "NamedObjMgr::SetVar( " << key << " ...) Bad VarName " << endl;
230 return(false);
231 }
[2755]232 ZSync zs(*myMutex); zs.NOp();
[1199]233#ifdef SANS_EVOLPLANCK
234 bool fg = true;
235#else
[1164]236 bool fg = myVars->HasKey(key);
[1199]237#endif
[1164]238 myVars->SetS(key, val);
[1224]239 // cout << " DEBUG::SetVar " << *myVars << endl;
[1164]240 return(fg);
241}
242
243/* --Methode-- */
244bool NamedObjMgr::HasVar(string const & key)
245{
[2218]246 if ((key.length() < 1) || (! isalpha(key[0])) ) {
247 cout << "NamedObjMgr::HasVar( " << key << ") Bad VarName " << endl;
248 return(false);
249 }
[2755]250 ZSync zs(*myMutex); zs.NOp();
[1199]251#ifdef SANS_EVOLPLANCK
[1547]252 DVList::ValList::const_iterator it;
253 for(it=myVars->Begin(); it!= myVars->End(); it++)
254 if ((*it).first == key) return true;
[1199]255 return(false);
256#else
[1164]257 return(myVars->HasKey(key));
[1199]258#endif
[1164]259}
260
261/* --Methode-- */
262bool NamedObjMgr::DeleteVar(string const & key)
263{
[2218]264 if ((key.length() < 1) || (! isalpha(key[0])) ) {
265 cout << "NamedObjMgr::DeleteVar( " << key << ") Bad VarName " << endl;
266 return(false);
267 }
[2755]268 ZSync zs(*myMutex); zs.NOp();
[1199]269#ifdef SANS_EVOLPLANCK
270 return(false);
271#else
[1164]272 return(myVars->DeleteKey(key));
[1199]273#endif
[1164]274}
275
276/* --Methode-- */
277string NamedObjMgr::GetVar(string const & key)
278{
[2218]279 if ((key.length() < 1) || (! isalpha(key[0])) ) {
280 cout << "NamedObjMgr::GetVar( " << key << ") Bad VarName " << endl;
281 return("");
282 }
[2755]283 ZSync zs(*myMutex); zs.NOp();
[1224]284 // cout << " DEBUG::GetVar " << *myVars << endl;
[1164]285 return(myVars->GetS(key));
286}
287
288/* --Methode-- */
289DVList& NamedObjMgr::GetVarList()
290{
[1224]291 // cout << " DEBUG::GetVarList " << *myVars << endl;
[2755]292 ZSync zs(*myMutex); zs.NOp();
[1164]293 return(*myVars);
294}
295
296/* --Methode-- */
[344]297bool NamedObjMgr::CreateDir(string & dirname)
[331]298{
[2755]299 ZSync zs(*myMutex); zs.NOp();
[2491]300 return CreateDir_P(dirname);
301}
302
303/* --Methode-- */
304bool NamedObjMgr::CreateDir_P(string & dirname)
305{
[333]306if ( !CheckDirName(dirname) ) {
307 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
[344]308 return(false);
[333]309 }
310NObjDirList::iterator it = myDirs->find(dirname);
311if (it != myDirs->end()) {
312 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
[344]313 return(false);
[333]314 }
315myDirId++;
316nobj_diritem di;
317di.id = myDirId;
318di.nobj = 0;
[344]319di.lock = false;
320di.keepold = false;
[333]321(*myDirs)[dirname] = di;
322if (myImgApp) {
323 string str = '/' + dirname;
[2492]324 if ( !_fgimgapp ) myImgApp->LockMutex();
[333]325 (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
[2492]326 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
327}
[449]328if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
[344]329return(true);
[331]330}
331
332/* --Methode-- */
[344]333bool NamedObjMgr::DeleteDir(string & dirname)
[331]334{
[333]335if ( !CheckDirName(dirname) ) {
336 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
[344]337 return(false);
[333]338 }
[2755]339ZSync zs(*myMutex); zs.NOp();
[333]340NObjDirList::iterator it = myDirs->find(dirname);
341if (it == myDirs->end()) {
342 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
[344]343 return(false);
[333]344 }
345if ((*it).second.nobj > 0) {
346 cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
[344]347 return(false);
[333]348 }
[344]349if ((*it).second.lock ) {
350 cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
351 return(false);
352 }
[333]353if ((*it).second.id < 50) {
354 cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
[344]355 return(false);
[333]356 }
357
[2490]358if (myImgApp) {
[2492]359 if ( !_fgimgapp ) myImgApp->LockMutex();
[333]360 (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
[2492]361 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[2490]362}
[333]363myDirs->erase(it);
[449]364if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
[344]365return(true);
[331]366}
367
368/* --Methode-- */
[344]369void NamedObjMgr::LockDir(string & dirname)
[331]370{
[2755]371ZSync zs(*myMutex); zs.NOp();
[344]372if ( !CheckDirName(dirname) ) return;
373NObjDirList::iterator it = myDirs->find(dirname);
374if (it == myDirs->end()) return;
375(*it).second.lock = true;
[449]376if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
[344]377return;
378}
379
380/* --Methode-- */
381void NamedObjMgr::UnlockDir(string & dirname)
382{
[2755]383ZSync zs(*myMutex); zs.NOp();
[344]384if ( !CheckDirName(dirname) ) return;
385NObjDirList::iterator it = myDirs->find(dirname);
386if (it == myDirs->end()) return;
387(*it).second.lock = true;
[449]388if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
[344]389return;
390}
391
392/* --Methode-- */
393void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold)
394{
[2755]395ZSync zs(*myMutex); zs.NOp();
[344]396if ( !CheckDirName(dirname) ) return;
397NObjDirList::iterator it = myDirs->find(dirname);
398if (it == myDirs->end()) return;
399(*it).second.keepold = keepold;
[449]400if (!verbeux) return;
[344]401cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << " -> ";
402if ( keepold ) cout << " True " << endl;
403else cout << " False " << endl;
404return;
405}
406
407
408/* --Methode-- */
409bool NamedObjMgr::SetCurrentDir(string & dirname)
410{
[2755]411ZSync zs(*myMutex); zs.NOp();
[333]412if ( !CheckDirName(dirname) ) {
413 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
[344]414 return(false);
[333]415 }
416NObjDirList::iterator it = myDirs->find(dirname);
417if (it == myDirs->end()) {
418 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
[344]419 return(false);
[333]420 }
421*currDir = dirname;
[449]422if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
[344]423return(true);
[331]424}
425
426/* --Methode-- */
[333]427void NamedObjMgr::GetCurrentDir(string & dirname)
428{
[2755]429ZSync zs(*myMutex); zs.NOp();
[333]430dirname = *currDir;
431}
432
433/* --Methode-- */
434void NamedObjMgr::ListDirs(string & patt)
435{
[2755]436ZSync zs(*myMutex); zs.NOp();
[333]437NObjDirList::iterator it;
438string cn;
439cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
440int k = 0;
441for(it= myDirs->begin(); it != myDirs->end(); it++) {
442 cn = (*it).first;
443 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
444 k++;
[344]445 cout << k << "- " << (*it).first;
446 if ( (*it).second.lock ) cout << " Locked " ;
447 if ( (*it).second.keepold ) cout << " KeepOld " ;
448 cout << " (Id= " << (*it).second.id << " NbObj= " << (*it).second.nobj << ")" << endl;
449
[333]450 }
451}
452
453/* --Methode-- */
454void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
455{
[2755]456ZSync zs(*myMutex); zs.NOp();
[333]457NObjDirList::iterator it;
458string cn;
459for(it= myDirs->begin(); it != myDirs->end(); it++) {
460 cn = (*it).first;
461 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
462 lstd.push_back(cn);
463 }
464}
465
466/* --Methode-- */
[368]467void NamedObjMgr::CleanDir(string & dirname)
[331]468{
[2755]469ZSync zs(*myMutex); zs.NOp();
[2491]470CleanDir_P(dirname);
471}
472
473/* --Methode-- */
474void NamedObjMgr::CleanDir_P(string & dirname)
475{
[368]476if ( !CheckDirName(dirname) ) {
477 cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
[380]478 // return(false); $CHECK$ illegal return value in void function
[368]479 }
480NObjDirList::iterator itr = myDirs->find(dirname);
481if (itr == myDirs->end()) {
482 cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
[380]483 // return(false); $CHECK$ illegal return value in void function
[368]484 }
[331]485
[368]486int did = (*itr).second.id;
487NObjList::iterator it;
488list<int>::iterator iwr;
489bool nodisp = true;
490list<string> odel;
491for(it = myObjs->begin(); it != myObjs->end(); it++) {
492 if ((*it).second.dirid != did) continue;
493 nodisp = true;
494 if (myImgApp)
495 for(iwr=(*it).second.wrsid.begin(); iwr != (*it).second.wrsid.end(); iwr++)
496 if (myImgApp->CheckWRsId(*iwr)) { nodisp = false; break; }
497 if (nodisp) odel.push_back((*it).first);
498 }
499list<string>::iterator ii;
[2757]500for(ii=odel.begin(); ii != odel.end(); ii++) DelObj_P(*ii,true);
[2490]501if (myImgApp) {
[2492]502 if ( !_fgimgapp ) myImgApp->LockMutex();
[685]503 (myImgApp->ObjMgrW())->UpdateList(did);
[2492]504 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[331]505}
[2490]506}
[331]507
[333]508
[368]509
[165]510//++
511// Titre Gestion de la liste des objets
512//--
513//++
[295]514// void AddObj(AnyDataObj* obj, string& nom)
[165]515// Ajoute l'objet "obj" à la liste, identifié par "nom".
516// Si un objet de même nom existe, l'ancien objet est renommé en concaténant
517// un numéro à son nom.
518// void DelObj(string const& nom, bool fgd=true)
519// Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
520// void DelObjects(string const& patt, bool fgd=true)
521// Supprime l'ensemble des objets dont le nom correspond au patron "patt".
522// Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
[295]523// AnyDataObj* GetObj(string const& nom)
[165]524// Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
525// pas dans la liste.
526// void RenameObj(string const& nom, string& nomnew)
527// Change le nom d'un objet dans la liste.
[463]528// void CopyObj(string const& nom, string& nomcp)
529// Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
[165]530//--
531
532/* --Methode-- */
[344]533bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
[165]534{
[2755]535 ZSync zs(*myMutex); zs.NOp();
[2491]536 return AddObj_P(obj, nom, crd);
537}
[165]538
[2491]539/* --Methode-- */
540bool NamedObjMgr::AddObj_P(AnyDataObj* obj, string & nom, bool crd)
541{
542
[344]543if (obj == NULL) return(false);
[333]544// On verifie si l'objet est deja dans la liste
545NObjList::iterator it;
546for(it = myObjs->begin(); it != myObjs->end(); it++) {
547 if ((*it).second.obj == obj) {
548 cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
[344]549 return(false);
[333]550 }
551 }
552string nobj;
553string nrep;
554char buff[32];
555int did = ParseObjectName(nom, nrep, nobj);
556if (did == 0) {
557 if (!crd) {
558 cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
[344]559 return(false);
[333]560 }
[2491]561 else { CreateDir_P(nrep); did = myDirId; }
[333]562 }
[165]563
[466]564// Si c'est le repertoire /autoc, on nettoie
565if (nrep == "autoc") {
[2491]566 CleanDir_P(nrep);
[368]567 }
568
[165]569myNObj++;
[2218]570if ((nobj.length() < 1) || (! isalpha(nobj[0]) ) ) {
571 cout << "NamedObjMgr::AddObj() bad object name " << nobj ;
[333]572 sprintf(buff,"O%d", myNObj);
573 nobj = buff;
[2218]574 cout << " changed to " << nobj << endl;
[333]575 }
576
577nom = '/' + nrep + '/' + nobj;
[344]578NObjDirList::iterator itr = myDirs->find(nrep);
579if ((*itr).second.lock) {
580 cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
581 return(false);
582 }
[333]583it = myObjs->find(nom);
[165]584if (it != myObjs->end()) { // l'objet existe deja
[466]585 if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
[368]586 sprintf(buff, "%d", (*it).second.oid);
[466]587 string nomnew = "/autoc/" + nobj + buff;
[2491]588 RenameObj_P(nom, nomnew);
[368]589 }
590 else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
[333]591 string on,od;
[335]592// ParseObjectName((*it).first, od, on);
[333]593 sprintf(buff, "%d", (*it).second.oid);
[335]594 string nomnew = "/old/" + nobj + buff;
[2491]595 RenameObj_P(nom, nomnew);
[333]596 }
[344]597 else { // Sinon, on remplace l'objet
598 cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
[2491]599 DelObj_P(nom);
[344]600 }
[165]601 }
602
603nobj_item no;
604no.obj = obj;
[295]605no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
[333]606no.oid = myNObj;
607no.dirid = did;
[331]608(*myObjs)[nom] = no;
[333]609
610(*itr).second.nobj++;
611
[2490]612if (myImgApp != NULL) {
[2492]613 if ( !_fgimgapp ) myImgApp->LockMutex();
[2490]614 if ( (myImgApp->ObjMgrW())->Visible() ) {
615 string oln = nobj + " (T= " + no.obja->GetDataObjType() + ")" ;
616 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
[685]617 }
[2492]618 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[2490]619}
[449]620if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
[295]621 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
[344]622return(true);
[165]623}
624
[1224]625bool NamedObjMgr::AddObj(AnyDataObj& obj, string & nom, bool crd)
626{
[2755]627ZSync zs(*myMutex); zs.NOp();
[1224]628NObjMgrAdapter* adap = GetServiceObj()->GetAdapter(&obj);
629if (adap == NULL) {
630 cout << "NamedObjMgr::AddObj() No Adapter ! " << nom << endl;
631 return(false);
632}
[1315]633AnyDataObj * cloneobj = adap->CloneDataObj(true);
[1224]634delete adap;
635if (cloneobj == NULL) {
636 cout << "NamedObjMgr::AddObj() Pb cloning object ! " << nom << endl;
637 return(false);
638}
[2491]639return ( AddObj_P(cloneobj , nom, crd) );
[1224]640}
641
[165]642/* --Methode-- */
[344]643bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
[165]644{
[2755]645 ZSync zs(*myMutex); zs.NOp();
[2491]646 return RenameObj_P(nom, nomnew);
647}
648
649/* --Methode-- */
650bool NamedObjMgr::RenameObj_P(string & nom, string& nomnew)
651{
[333]652string n1,r1,n2,r2;
[344]653int dids = ParseObjectName(nom, r1, n1);
654NObjDirList::iterator itr1 = myDirs->find(r1);
[333]655int did = ParseObjectName(nomnew, r2, n2);
[344]656NObjDirList::iterator itr2 = myDirs->find(r2);
657
[333]658if (did == 0) {
659 cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
[344]660 return(false);
[2218]661}
[333]662nom = '/' + r1 + '/' + n1;
663nomnew = '/' + r2 + '/' + n2;
664NObjList::iterator it1 = myObjs->find(nom);
665if (it1 == myObjs->end()) {
666 cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl;
[344]667 return(false);
[2218]668}
669if ((n2.length() < 1) || (! isalpha(n2[0])) ) {
670 cout << "NamedObjMgr::RenameObj() Error - bad new object name" << n2 << endl;
671 return(false);
672}
[333]673NObjList::iterator it2 = myObjs->find(nomnew);
674if (it2 != myObjs->end()) {
675 cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
[344]676 return(false);
[333]677 }
678
[344]679if ( (*itr1).second.lock || (*itr2).second.lock ) {
680 cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !"
681 << endl;
682 return(false);
683 }
684
685
[333]686nobj_item no = (*it1).second;
687no.dirid = did;
688myObjs->erase(it1);
689NObjDirList::iterator itr = myDirs->find(r1);
690(*itr).second.nobj--;
691(*myObjs)[nomnew] = no;
692itr = myDirs->find(r2);
693(*itr).second.nobj++;
[685]694
[2490]695if (myImgApp != NULL) {
[2492]696 if ( !_fgimgapp ) myImgApp->LockMutex();
[2490]697 if ( (myImgApp->ObjMgrW())->Visible() ) {
698 (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
699 string oln = n2 + " (T= " + no.obja->GetDataObjType() + ")" ;
700 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
701 }
[2492]702 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[685]703}
[449]704if (verbeux)
705 cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
[344]706return(true);
[331]707}
708
709/* --Methode-- */
[463]710bool NamedObjMgr::CopyObj(string & nom, string& nomcp)
711{
[2755]712ZSync zs(*myMutex); zs.NOp();
[463]713if(nomcp.length()<=0)
714 {cout<<"NamedObjMgr::CopyObj() Error, copied obj name "<<nomcp<<" not valid"<<endl;
715 return(false);}
[2755]716NObjMgrAdapter* obnom = GetObjAdapter_P(nom);
[463]717if(obnom==NULL)
718 {cout<<"NamedObjMgr::CopyObj() Error - No "<<nom<<" object !"<<endl;
719 return(false);}
[1165]720AnyDataObj* obnomcp = obnom->CloneDataObj();
[463]721if(obnomcp==NULL) return(false);
[2491]722if(! AddObj_P(obnomcp,nomcp,false) ) {delete obnomcp; return(false);}
[463]723return true;
724}
725
726/* --Methode-- */
[344]727bool NamedObjMgr::DelObj(string & nom, bool fgd)
[331]728{
[2755]729 ZSync zs(*myMutex); zs.NOp();
[2491]730 return DelObj_P(nom, fgd);
731}
732
733/* --Methode-- */
734bool NamedObjMgr::DelObj_P(string & nom, bool fgd)
735{
[333]736string n1,r1;
[685]737int did = ParseObjectName(nom, r1, n1);
[333]738nom = '/' + r1 + '/' + n1;
[165]739NObjList::iterator it = myObjs->find(nom);
[344]740if (it == myObjs->end()) return(false);
741NObjDirList::iterator itr = myDirs->find(r1);
742if ( (*itr).second.lock ) {
743 cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
744 return(false);
745 }
[165]746list<int>::iterator ii;
747if (myImgApp) {
748//DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
[2492]749// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
750 bool fglock = (_fgimgapp) ? false : true;
751 if (fglock) myImgApp->LockMutex();
[165]752 for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
753 myImgApp->DelWRsId((*ii));
[2492]754 if (fglock) myImgApp->UnlockMutex(true);
[165]755}
[314]756delete (*it).second.obja; // destruction de l'adaptateur
[165]757if (fgd) delete (*it).second.obj;
[333]758
[2490]759if (myImgApp != NULL) {
[2492]760 if ( !_fgimgapp ) myImgApp->LockMutex();
[2490]761 if ( (myImgApp->ObjMgrW())->Visible() ) {
762 int olid = (*it).second.oid;
763 (myImgApp->ObjMgrW())->DelObjList(did, olid);
764 }
[2492]765 if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[685]766}
[165]767myObjs->erase(it);
[333]768(*itr).second.nobj--;
769
[685]770
[449]771if (!verbeux) return(true);
[165]772if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
773else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
[344]774return(true);
[165]775}
776
777/* --Methode-- */
[344]778bool NamedObjMgr::DelObj_Id(int oid)
[165]779{
[2755]780ZSync zs(*myMutex); zs.NOp();
[333]781NObjList::iterator it;
782string nom;
783bool of = false;
784for(it = myObjs->begin(); it != myObjs->end(); it++)
785 if ( (*it).second.oid == oid ) {
786 of = true; nom = (*it).first;
787 break;
788 }
[2757]789if (of) return(DelObj_P(nom, true));
[344]790else return(false);
[331]791}
792
793/* --Methode-- */
794void NamedObjMgr::DelObjects(string & patt, bool fgd)
795{
[2755]796ZSync zs(*myMutex); zs.NOp();
[333]797string n1,r1;
798ParseObjectName(patt, r1, n1);
799patt = '/' + r1 + '/' + n1;
[165]800NObjList::iterator it;
801list<string> odel;
802string cn;
803for(it = myObjs->begin(); it != myObjs->end(); it++) {
804 cn = (*it).first;
805 if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
806 }
807list<string>::iterator ii;
[2491]808for(ii=odel.begin(); ii != odel.end(); ii++) DelObj_P(*ii, fgd);
[165]809}
810
811/* --Methode-- */
[331]812AnyDataObj* NamedObjMgr::GetObj(string & nom)
[165]813{
[2755]814ZSync zs(*myMutex); zs.NOp();
815return GetObj_P(nom);
816}
817
818/* --Methode-- */
819AnyDataObj* NamedObjMgr::GetObj_P(string & nom)
820{
[333]821string n1,r1;
822ParseObjectName(nom, r1, n1);
823nom = '/' + r1 + '/' + n1;
[165]824NObjList::iterator it = myObjs->find(nom);
825if (it == myObjs->end()) return(NULL);
826return((*it).second.obj);
827}
828
829/* --Methode-- */
[331]830NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
[295]831{
[2755]832ZSync zs(*myMutex); zs.NOp();
833return GetObjAdapter_P(nom);
834}
835
836/* --Methode-- */
837NObjMgrAdapter* NamedObjMgr::GetObjAdapter_P(string & nom)
838{
[333]839string n1,r1;
840ParseObjectName(nom, r1, n1);
841nom = '/' + r1 + '/' + n1;
[295]842NObjList::iterator it = myObjs->find(nom);
843if (it == myObjs->end()) return(NULL);
844return((*it).second.obja);
845}
846
847/* --Methode-- */
[331]848void NamedObjMgr::ListObjs(string & patt)
[165]849{
[2755]850ZSync zs(*myMutex); zs.NOp();
[331]851int k;
852AnyDataObj* obj=NULL;
853string ctyp;
854char strg[256];
855
[333]856string n1,r1;
857ParseObjectName(patt, r1, n1);
858patt = '/' + r1 + '/' + n1;
859 cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
[331]860NObjList::iterator it; k = 0;
[333]861string cn;
[331]862for(it = myObjs->begin(); it != myObjs->end(); it++) {
[333]863 cn = (*it).first;
864 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
[331]865 obj = (*it).second.obj;
866 ctyp = typeid(*obj).name();
867 sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
868 ctyp = strg;
869 cout << ctyp << "\n" ;
870 k++;
871}
872cout << endl;
[165]873return;
874}
875
876/* --Methode-- */
[333]877void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
[165]878{
[2755]879ZSync zs(*myMutex); zs.NOp();
[333]880string n1,r1;
881if (patt.length() < 1) return;
882bool fgr = (patt[0] == '/') ? true : false;
883ParseObjectName(patt, r1, n1);
884patt = '/' + r1 + '/' + n1;
885NObjList::iterator it;
886string cn;
887for(it = myObjs->begin(); it != myObjs->end(); it++) {
888 cn = (*it).first;
889 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
890 if (fgr) lst.push_back(cn);
891 else {
892 ParseObjectName(cn, r1, n1);
893 lst.push_back(n1);
894 }
895 }
[165]896}
897
898//++
899// Titre Entrées-Sorties (I/O) sur les objets
900//--
901//++
902// void ReadObj(PInPersist& s, int num=-1)
903// Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
904// et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
905// sur le flot "s" sont créés et ajoutés à la liste.
906// void ReadObj(string const & nomppf, string nobj="")
907// Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
908// à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
909// composé à partir du nom de fichier.
910//--
911
912/* --Methode-- */
[331]913void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
[165]914{
[2755]915ZSync zs(*myMutex); zs.NOp();
[495]916PPersist* ppobj=NULL;
[165]917bool ok = true;
[495]918#ifdef SANS_EVOLPLANCK
[165]919TRY{
920 PInPersist pis(flnm);
[495]921 ppobj = PPersistMgr::ReadObject(pis);
922 if (ppobj == NULL) ok = false;
[165]923} CATCH(merr)
924 { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
925 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
[495]926#else
927try {
928 PInPersist pis(flnm);
929 ppobj = pis.ReadObject();
930 }
931catch (IOExc iox) {
932 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
933 ok = false;
934 }
935#endif
[165]936if (!ok) return;
937if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
[2491]938AddObj_P(ppobj->DataObj(), nobj, true);
[685]939cout << "NamedObjMgr::ReadObj(...) object " << nobj << " read from file " << endl;
[165]940return;
941}
[2645]942/* --Methode-- */
943void NamedObjMgr::ReadObj(vector<string> & flnm_objname)
944// flnm_objname[0] = nom du fichier .ppf
945// flnm_objname[1...] = nom des tags des objects a lire
946{
947if(flnm_objname.size()<2) return;
[2755]948ZSync zs(*myMutex); zs.NOp();
[2645]949int nread=0;
950try {
951 PInPersist pis(flnm_objname[0]);
952 for(int i=1;i<flnm_objname.size();i++) {
953 bool ok = pis.GotoNameTag(flnm_objname[i]);
954 if(!ok) {
955 cout<<"NamedObjMgr::ReadObj(...) Unknown object: "<<flnm_objname[i]<<endl;
956 continue;
957 }
958 PPersist *ppobj = pis.ReadObject();;
959 if(ppobj==NULL) {
960 cout<<"NamedObjMgr::ReadObj(...) impossible to read "<<flnm_objname[i]<<endl;
961 continue;
962 }
963 AddObj_P(ppobj->DataObj(),flnm_objname[i],true);
964 nread++;
965 cout<<"NamedObjMgr::ReadObj(...) object "<<flnm_objname[i]<<" read from file "<<endl;
966 }
967} catch (IOExc iox) {
968 cerr<<"NamedObjMgr::ReadObj()/Error Exception - Msg= "<<iox.Msg()<<endl;
969}
970cout<<nread<<" objects have been read"<<endl;
971return;
972}
[165]973
974/* --Methode-- */
975void NamedObjMgr::ReadObj(PInPersist& s, int num)
976{
[2755]977ZSync zs(*myMutex); zs.NOp();
978ReadObj_P(s, num);
979}
980
981/* --Methode-- */
982void NamedObjMgr::ReadObj_P(PInPersist& s, int num)
983{
[2180]984int_4 i; // $CHECK$ int -> int_4 a cause de TagKey
985#ifdef SANS_EVOLPLANCK
986int_4 cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
987#endif
[165]988int n0, n1;
989bool ok = true;
990PPersist* obj=NULL;
991string nom;
992
[449]993int nread = 0;
[2460]994int nbtags = 0;
995#ifdef SANS_EVOLPLANCK
996nbtags = s.NbTags();
997#else
998nbtags = s.NbNameTags();
999#endif
1000if ( (nbtags < 1) || (num >= nbtags) ) {
[165]1001 if (num >= 0) {
[495]1002 cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
[2460]1003 << nbtags << endl;
[165]1004 return;
1005 }
[495]1006
1007#ifdef SANS_EVOLPLANCK
[165]1008 TRY {
1009 obj = PPersistMgr::ReadObject(s);
1010 if (obj == NULL) ok = false;
1011 } CATCH(merr) {
1012 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
1013 ok = false;
1014 } ENDTRY;
[495]1015#else
1016try {
1017 obj = s.ReadObject();
1018 }
1019catch (IOExc iox) {
1020 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
1021 ok = false;
1022 }
1023#endif
1024
[165]1025 if (!ok) return;
1026 nom = "";
[2491]1027 AddObj_P(obj->DataObj(), nom, false);
[449]1028 nread++;
[165]1029}
1030
[2460]1031if (num < 0) { n0 = 0; n1 = nbtags; }
[165]1032else { n0 = num; n1 = num+1; }
1033for(i=n0; i<n1; i++) {
[495]1034#ifdef SANS_EVOLPLANCK
[165]1035 key = s.TagKey(i, cid, ln);
1036 if (ln <= 0) nom = "";
1037 else nom = s.TagName(i);
1038 s.GotoTag(i);
1039 TRY {
1040 obj = PPersistMgr::ReadObject(s);
1041 if (obj == NULL) ok = false;
1042 } CATCH(merr) {
1043 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
1044 ok = false;
1045 } ENDTRY;
[495]1046#else
[2460]1047 s.GotoNameTagNum(i);
[584]1048 nom = s.GetTagName(i);
[495]1049 try {
1050 obj = s.ReadObject();
1051 }
1052 catch (IOExc iox) {
1053 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
1054 ok = false;
1055 }
1056#endif
[2491]1057 if (ok) { AddObj_P(obj->DataObj(), nom, true); nread++; }
[165]1058}
1059
[449]1060cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
[165]1061return;
1062}
1063/* --Methode-- */
1064void NamedObjMgr::ReadAll(string const & flnm)
1065{
[2755]1066ZSync zs(*myMutex); zs.NOp();
[2701]1067#ifdef SANS_EVOLPLANCK
[165]1068bool ok = true;
1069PPersist* obj=NULL;
1070
[2180]1071PInPersist* ppin=NULL;
[165]1072TRY{
1073 ppin = new PInPersist(flnm);
1074 if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
1075 else obj = NULL;
1076} CATCH(merr)
1077 { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
[2701]1078 (long)merr, PeidaExc(merr)); ok = false; }
1079ENDTRY;
[165]1080if (!ok) return;
1081if (obj) {
1082 string nom = servnobjm->FileName2Name(flnm);
[2491]1083 AddObj_P(obj->DataObj(), nom, false);
[165]1084 }
[2755]1085else ReadObj_P((*ppin), -1);
[165]1086delete ppin;
[2701]1087#else
1088try {
1089 PInPersist pis(flnm);
1090 if (pis.NbNameTags() >= 1) {
1091 if (pis.NbNameTags() < pis.NbTopLevelObjects()) {
1092 cout << "NamedObjMgr::ReadAll()/Warning File " << flnm << " NbNameTags="
1093 << pis.NbNameTags() << " < NbTopLevelObjects= "
1094 << pis.NbTopLevelObjects() << endl;
1095 cout << " ... Reading " << pis.NbNameTags() << " objects at NameTags " ;
1096 }
[2755]1097 ReadObj_P(pis, -1);
[2701]1098 return;
1099 }
1100
1101 string nom = servnobjm->FileName2Name(flnm);
1102 int kn = 1;
1103 for(int ii=0; ii<pis.NbTopLevelObjects(); ii++) {
1104 PPersist* obj = pis.ReadObject();
1105 if (!obj) continue;
1106 AddObj_P(obj->DataObj(), nom, false);
1107 kn++;
1108 nom += (string)MuTyV(kn);
1109 }
1110}
1111catch (IOExc& iox) {
1112 cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
1113}
1114#endif
[165]1115return;
1116}
1117
1118/* --Methode-- */
[331]1119void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
[165]1120{
[2755]1121ZSync zs(*myMutex); zs.NOp();
[293]1122#ifdef SANS_EVOLPLANCK
[2180]1123bool ok = false;
[709]1124RzImage* obj=NULL;
[495]1125TRY{
[165]1126 obj = RzReadFits((char*)flnm.c_str());
1127 if (obj == NULL) ok = false;
[709]1128 else ok = true;
[165]1129} CATCH(merr) {
1130 printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
1131 ok = false;
1132} ENDTRY;
[709]1133
1134if (ok && (obj != NULL)) {
[165]1135 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
[2491]1136 AddObj_P((AnyDataObj*)obj, nobj);
[165]1137}
[1105]1138#else
[1321]1139 try {
1140 FITS_AutoReader fiar(flnm);
[1335]1141 char bun[16];
1142 int nhdu = fiar.NbBlocks();
[1321]1143 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
1144 string name;
1145 AnyDataObj* obj;
[1513]1146 int kon = 1;
[1321]1147 for(int k=1; k<=nhdu; k++) {
1148 obj = fiar.ReadObject(k);
[1330]1149 if (obj) {
[1321]1150 cout << " NamedObjMgr::ReadFits() " << (string)typeid(*obj).name()
1151 << " read From HDU " << k << endl;
[1513]1152 if (typeid(*obj) == typeid(DVList)) {
1153 delete obj;
1154 continue;
1155 }
1156 if (kon > 1) {
1157 sprintf(bun, "%d", kon);
[1330]1158 name = nobj + bun;
1159 }
1160 else name = nobj;
[2491]1161 AddObj_P(obj, name, false);
[1513]1162 kon++;
[1330]1163 }
[1321]1164 else cerr << " NamedObjMgr::ReadFits() NULL pointer from FITS_AutoReader" << endl;
1165 }
1166 }
1167 catch(PThrowable & exc) {
1168 cerr << " NamedObjMgr::ReadFits() / Error - Catched Exception \n "
1169 << " Type= " << (string)typeid(exc).name()
1170 << " - Msg= " << exc.Msg() << endl;
1171
1172 }
[1105]1173#endif
1174
[165]1175return;
1176}
1177
[2491]1178/* --Methode-- */
1179void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
1180{
[2755]1181 ZSync zs(*myMutex); zs.NOp();
[2491]1182 SaveObj_P(nom, s, keeppath);
1183}
[165]1184
1185static int key_for_write = 5000;
1186/* --Methode-- */
[2491]1187void NamedObjMgr::SaveObj_P(string & nom, POutPersist& s, bool keeppath)
[165]1188{
[333]1189if (nom.length() < 1) return;
1190string nob,rep;
1191ParseObjectName(nom, rep, nob);
1192nom = '/' + rep + '/' + nob;
[295]1193NObjMgrAdapter* obja=NULL;
[333]1194string nomf = (keeppath) ? nom : nob;
[2755]1195obja = GetObjAdapter_P(nom);
[295]1196if (obja == NULL) return;
[165]1197printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
[295]1198 nom.c_str(), typeid(*(obja->GetDataObj())).name());
[333]1199obja->SavePPF(s, nomf);
[165]1200return;
1201}
1202
1203/* --Methode-- */
[333]1204void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
1205{
[2755]1206ZSync zs(*myMutex); zs.NOp();
[333]1207string n1,r1;
1208if (patt.length() < 1) return;
1209bool keeppath = (patt[0] == '/') ? true : false;
1210ParseObjectName(patt, r1, n1);
1211patt = '/' + r1 + '/' + n1;
1212
1213bool ok = true;
[2180]1214POutPersist* pout=NULL;
[495]1215#ifdef SANS_EVOLPLANCK
[333]1216TRY{
1217 pout = new POutPersist(flnm);
1218} CATCH(merr)
1219 { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
1220 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
[495]1221#else
1222try {
1223 pout = new POutPersist(flnm);
1224}
1225catch (IOExc iox) {
1226 cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
1227 ok = false;
1228}
1229#endif
[333]1230if (!ok) return;
1231NObjList::iterator it;
1232string cn;
1233for(it = myObjs->begin(); it != myObjs->end(); it++) {
1234 cn = (*it).first;
1235 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
[2491]1236 SaveObj_P(cn, (*pout), keeppath);
[333]1237 }
1238delete pout;
1239return;
1240}
1241
1242/* --Methode-- */
[2669]1243void NamedObjMgr::SaveListObjects(vector<string> &liste)
1244// Les n-1 premiers elements (liste[0 -> n-2]) contiennent
1245// les noms des objects a mettre dans le fichier ppf
1246// dont le nom est le dernier argument (liste[n-1])
1247{
[2755]1248 ZSync zs(*myMutex); zs.NOp();
[2669]1249
1250 if(liste.size()<2) {
1251 cerr<<"NamedObjMgr::SaveListObjects()/Error not enough argument"<<endl;
1252 return;
1253 }
1254
1255 // open ppf file
1256 string ppfname = liste[liste.size()-1];
1257 POutPersist* pout=NULL;
1258 try {
1259 pout = new POutPersist(ppfname);
1260 } catch(IOExc iox) {
1261 cerr<<"NamedObjMgr::SaveObjects()/Error Exception - Msg= "<<iox.Msg()<<endl;
1262 return;
1263 }
1264
1265 // put objects in ppf file
1266 for(int i=0;i<liste.size()-1;i++) {
1267 bool keeppath = (liste[i][0] == '/') ? true : false;
1268 SaveObj_P(liste[i], (*pout), keeppath);
1269 }
1270
1271 // close ppf file
1272 delete pout;
1273
1274 return;
1275}
1276
1277/* --Methode-- */
[165]1278void NamedObjMgr::SaveAll(string const& flnm)
1279{
[2755]1280ZSync zs(*myMutex); zs.NOp();
[165]1281bool ok = true;
1282
[2180]1283POutPersist* pout=NULL;
[495]1284#ifdef SANS_EVOLPLANCK
[165]1285TRY{
1286 pout = new POutPersist(flnm);
1287} CATCH(merr)
1288 { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
1289 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
[495]1290#else
1291try {
1292 pout = new POutPersist(flnm);
1293}
1294catch (IOExc iox) {
1295 cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
1296 ok = false;
1297}
1298#endif
[165]1299if (!ok) return;
[332]1300NObjList::iterator it;
1301string no;
1302for(it = myObjs->begin(); it != myObjs->end(); it++) {
1303 no = (*it).first;
[2491]1304 SaveObj_P(no, (*pout), true);
[332]1305 }
[165]1306delete pout;
1307return;
1308}
1309
1310/* --Methode-- */
[331]1311void NamedObjMgr::SaveFits(string& nom, string const & flnm)
[165]1312{
[2755]1313ZSync zs(*myMutex); zs.NOp();
[2491]1314
[295]1315NObjMgrAdapter* obja=NULL;
[2755]1316obja = GetObjAdapter_P(nom);
[295]1317if (obja == NULL) return;
[2672]1318cout << " SaveFits: Object" << nom << " to FITS file " << flnm << endl;
[295]1319obja->SaveFits(flnm);
[293]1320return;
[165]1321}
1322
1323
1324
1325/* --Methode-- */
[331]1326void NamedObjMgr::PrintObj(string& nom)
[165]1327{
[2755]1328ZSync zs(*myMutex); zs.NOp();
[295]1329NObjMgrAdapter* obja=NULL;
[2755]1330obja = GetObjAdapter_P(nom);
[295]1331if (obja == NULL) return;
[594]1332AnyDataObj* ob = obja->GetDataObj();
1333if (ob == NULL) {
1334 cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
1335 return;
1336 }
1337string ctyp = typeid(*ob).name();
[295]1338cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
1339obja->Print(cout);
[165]1340
1341return;
1342}
1343
1344/* --Methode-- */
[331]1345void NamedObjMgr::DisplayObj(string& nom, string dopt)
[165]1346{
[2677]1347// Pas de display si option dopt = nodisp
1348if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1349
[2755]1350ZSync zs(*myMutex); zs.NOp();
[2491]1351
[295]1352NObjMgrAdapter* obja=NULL;
[2755]1353obja = GetObjAdapter_P(nom);
[295]1354if (obja == NULL) {
[594]1355 cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
[165]1356 return;
1357}
[594]1358if (obja->GetDataObj() == NULL) {
1359 cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
1360 return;
1361 }
[165]1362if (!myImgApp) return;
1363
[295]1364PIDrawer * dr = NULL;
1365P2DArrayAdapter* arr = NULL;
1366dr = obja->GetDrawer(dopt);
1367if (!dr) arr = obja->Get2DArray(dopt);
[165]1368
[295]1369if (!dr && !arr) {
1370 string ctyp = typeid(*(obja->GetDataObj())).name();
[594]1371 cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
[295]1372 return;
1373 }
1374
[165]1375int wrsid = 0;
1376
[344]1377string n1,r1;
1378ParseObjectName(nom, r1, n1);
1379
[2491]1380// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1381bool fglock = (_fgimgapp) ? false : true;
1382
[295]1383if (dr) {
1384 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
[2491]1385 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, dopt, "", 0, fglock);
1386 else wrsid = myImgApp->DispScDrawer( dr, n1, dopt, "", 0, fglock);
[295]1387 }
[2651]1388else if (arr) wrsid = myImgApp->DispImage(arr, n1, dopt, false, 0, fglock);
[165]1389
[2402]1390AddWRsId(nom, wrsid);
[295]1391return;
1392}
[165]1393
[295]1394/* --Methode-- */
[2651]1395void NamedObjMgr::DisplayImage(string& nom, string dopt, bool fgimagnav)
[295]1396{
[2677]1397// Pas de display si option dopt = nodisp
1398if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1399
[2755]1400ZSync zs(*myMutex); zs.NOp();
[2491]1401
[295]1402NObjMgrAdapter* obja=NULL;
[2755]1403obja = GetObjAdapter_P(nom);
[295]1404if (obja == NULL) {
[449]1405 cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
[295]1406 return;
1407}
[594]1408if (obja->GetDataObj() == NULL) {
1409 cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
1410 return;
1411 }
[295]1412if (!myImgApp) return;
1413
1414P2DArrayAdapter* arr = obja->Get2DArray(dopt);
[165]1415
[295]1416if (!arr) {
1417 string ctyp = typeid(*(obja->GetDataObj())).name();
[449]1418 cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
[295]1419 return;
1420 }
[165]1421
[344]1422string n1,r1;
1423ParseObjectName(nom, r1, n1);
1424
[2491]1425// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1426bool fglock = (_fgimgapp) ? false : true;
1427
[295]1428int wrsid = 0;
[2651]1429wrsid = myImgApp->DispImage(arr, n1, dopt, fgimagnav, 0, fglock);
[165]1430
[2402]1431AddWRsId(nom, wrsid);
[295]1432return;
1433}
1434/* --Methode-- */
[331]1435void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
[295]1436{
[2677]1437// Pas de display si option dopt = nodisp
1438if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1439
[2755]1440ZSync zs(*myMutex); zs.NOp();
[2491]1441
[295]1442NObjMgrAdapter* obja=NULL;
[2755]1443obja = GetObjAdapter_P(nom);
[295]1444if (obja == NULL) {
[449]1445 cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
[295]1446 return;
1447}
[594]1448if (obja->GetDataObj() == NULL) {
1449 cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
1450 return;
1451 }
[295]1452if (!myImgApp) return;
1453
1454P2DArrayAdapter* arr = obja->Get2DArray(dopt);
[165]1455
[295]1456if (!arr) {
1457 string ctyp = typeid(*(obja->GetDataObj())).name();
[449]1458 cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
[295]1459 return;
1460 }
[165]1461
[295]1462if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
1463 cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
[449]1464 << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
[295]1465 delete arr;
1466 return;
[165]1467 }
1468
[344]1469string n1,r1;
1470ParseObjectName(nom, r1, n1);
1471
[2491]1472// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1473bool fglock = (_fgimgapp) ? false : true;
1474
[295]1475int wrsid = 0;
1476PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
[2491]1477wrsid = myImgApp->Disp3DDrawer(sdr, n1, dopt, "", 0, fglock);
[2402]1478AddWRsId(nom, wrsid);
[295]1479return;
[165]1480}
1481
1482/* --Methode-- */
[331]1483void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
[486]1484 string& erx, string& ery, string& erz, string& wt,
1485 string& label, string dopt, bool fg3d)
[165]1486{
[2677]1487// Pas de display si option dopt = nodisp
1488if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1489
[2755]1490ZSync zs(*myMutex); zs.NOp();
[2491]1491
[2755]1492AnyDataObj* obj=GetObj_P(nom);
[165]1493if (obj == NULL) {
[449]1494 cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
[165]1495 return;
1496}
1497if (!myImgApp) return;
1498
[326]1499NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
1500if (nt == NULL) {
1501// if (typeid(*obj) != typeid(NTupleInterface)) {
[295]1502 string ctyp = typeid(*obj).name();
[449]1503 cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
[165]1504 return;
1505 }
1506
1507int wrsid = 0;
[1971]1508dopt = "defline " + dopt;
[165]1509
[344]1510string n1,r1;
1511ParseObjectName(nom, r1, n1);
1512
[2491]1513// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1514bool fglock = (_fgimgapp) ? false : true;
1515
[333]1516if ( fg3d && (nmz.length()>0) ) { // Display 3D
[326]1517 PINTuple3D* pin = new PINTuple3D(nt, false);
[165]1518 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
[486]1519 pin->SelectWt(wt.c_str());
1520 pin->SelectLabel(label.c_str());
[165]1521 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
1522 string titre = nmz + "%" + nmy + "%" + nmz;
[2491]1523 wrsid = myImgApp->Disp3DDrawer(pin, n1, dopt, titre, 0, fglock);
[165]1524}
1525else {
[326]1526 PINTuple* pin = new PINTuple(nt, false);
[165]1527 pin->SelectXY(nmx.c_str(), nmy.c_str());
[486]1528 pin->SelectWt(wt.c_str());
1529 pin->SelectLabel(label.c_str());
[165]1530 pin->SelectErrBar(erx.c_str(), ery.c_str());
[333]1531 string titre = nmy + "%" + nmx;
[2491]1532 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, dopt, titre, 0, fglock);
[165]1533 }
1534
[2402]1535AddWRsId(nom, wrsid);
[165]1536return;
1537}
1538
[339]1539/* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
[331]1540void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
[165]1541// Pour le display 2D ou 3D d'un ``GeneralFitData''.
1542//| nom = nom de l'objet GeneralFitData a representer.
1543//| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
1544//| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
1545//| Pour le display 2D, numvary="" string vide.
1546//| err = qu'elles erreurs faut il representer ?
1547//| - 2D : x y xy (display y=f(x))
1548//| - 3D : x y z xy xz yz xzy (display z=f(x,y))
1549//| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
1550//| les barres d'erreurs sont representees.
1551//| opt = options generales pour le display.
1552{
[2677]1553// Pas de display si option dopt = nodisp
1554if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1555
[2755]1556ZSync zs(*myMutex); zs.NOp();
[2491]1557
[2755]1558AnyDataObj* obj=GetObj_P(nom);
[165]1559if(obj == NULL)
[449]1560 {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
[165]1561 return;}
1562if(!myImgApp) return;
[295]1563if(typeid(*obj) != typeid(GeneralFitData))
1564 {string ctyp = typeid(*obj).name();
[449]1565 cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
[165]1566 return;}
1567
1568// Decodage des erreurs a representer
1569bool errx=false, erry=false, errz=false;
1570if(err.length()>0) {
[2180]1571 for(int i=0;i<(int_4)err.length();i++)
[165]1572 if (err[i]=='x' || err[i]=='X') errx = true;
1573 else if(err[i]=='y' || err[i]=='Y') erry = true;
1574 else if(err[i]=='z' || err[i]=='Z') errz = true;
1575}
1576// Decodage des numeros de variables en abscisse
[339]1577 int numvx=-1, numvy=-1;
1578 if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
1579 if(numvary.length()>0) numvy = atoi(numvary.c_str());
1580
[344]1581 string n1,r1;
1582 ParseObjectName(nom, r1, n1);
[2491]1583 // Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1584 bool fglock = (_fgimgapp) ? false : true;
[344]1585
[339]1586 int wrsid = 0;
1587 if(numvy>=0) { // display 3D
[165]1588 PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
1589 pigfd->SelectXY(numvx,numvy);
1590 pigfd->SelectErrBar(errx,erry,errz);
[2491]1591 wrsid = myImgApp->Disp3DDrawer(pigfd,n1,dopt,"",0,fglock);
[339]1592} else { // display 2D
[165]1593 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
1594 pigfd->SelectX(numvx);
1595 pigfd->SelectErrBar(errx,erry);
[2491]1596 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,dopt,"",0,fglock);
[165]1597}
1598
[2402]1599AddWRsId(nom, wrsid);
[1971]1600
[165]1601return;
1602}
1603
[1525]1604/* --Methode-- */
1605void NamedObjMgr::DisplayVector(string & nomvx, string& nomvy, string dopt)
1606// Pour l'affichage 2-D de points avec coordonnees definies par deux vecteurs
1607// nomvx et nomvy
1608{
[2677]1609// Pas de display si option dopt = nodisp
1610if ( (dopt == "nodisp") || (dopt == "nodisplay") ) return;
1611
[2755]1612ZSync zs(*myMutex); zs.NOp();
[2491]1613
[1525]1614#ifdef SANS_EVOLPLANCK
1615 cerr << " NamedObjMgr::DisplayVector() Error: Not implemented with PEIDA " << endl;
1616#else
1617
1618if(!myImgApp) return;
1619
1620AnyDataObj* obj;
[2755]1621obj = GetObj_P(nomvx);
[1525]1622if(obj == NULL) {
1623 cout << "NamedObjMgr::DisplayVector() Error , No such object " << nomvx << endl;
1624 return;
1625}
[2263]1626//Vector * vx = dynamic_cast<Vector *>(obj);
1627BaseArray* bax = dynamic_cast<BaseArray *>(obj);
1628if (bax == NULL) {
1629 cout << "NamedObjMgr::DisplayVector() Error " << nomvx << " not a BaseArray ! " << endl;
[1525]1630 return;
1631}
1632
[2755]1633obj = GetObj_P(nomvy);
[1525]1634if(obj == NULL) {
1635 cout << "NamedObjMgr::DisplayVector() Error , No such object " << nomvy << endl;
1636 return;
1637}
[2263]1638BaseArray* bay = dynamic_cast<BaseArray *>(obj);
1639if (bay == NULL) {
1640 cout << "NamedObjMgr::DisplayVector() Error " << nomvy << " not a BaseArray ! " << endl;
[1525]1641 return;
1642}
1643
[2263]1644Vector vx = *bax;
1645Vector vy = *bay;
[1525]1646Vector * cvx, * cvy;
1647
[2263]1648if (vx.Size() != vy.Size()) {
[1525]1649 cout << "NamedObjMgr::DisplayVector() Warning / Vx.Size() != Vy.Size() " << endl;
[2263]1650 if (vx.Size() < vy.Size()) {
1651 cvx = new Vector(vx);
1652 cvy = new Vector(vy.SubVector(Range(0, 0, vx.Size()-1)));
[1525]1653 }
1654 else {
[2263]1655 cvx = new Vector(vx.SubVector(Range(0, 0, vy.Size()-1)));
1656 cvy = new Vector(vy);
[1525]1657 }
1658}
1659else {
[2263]1660 cvx = new Vector(vx);
1661 cvy = new Vector(vy);
[1525]1662}
1663
1664POVectorAdapter * avx = new POVectorAdapter(cvx, true);
1665POVectorAdapter * avy = new POVectorAdapter(cvy, true);
1666PIYfXDrawer * vxydrw = new PIYfXDrawer(avx, avy, true);
1667
1668string nx,rx;
1669ParseObjectName(nomvx, rx, nx);
1670string ny,ry;
1671ParseObjectName(nomvy, ry, ny);
1672
[2491]1673// Si appel venant de PIStdImgApp, il ne faut pas locker le Mutex global de la boucle d'evts
1674bool fglock = (_fgimgapp) ? false : true;
1675
[1525]1676string title = ny + " (Y) vs. " + nx + " (X)";
1677// display 2D
[2491]1678myImgApp->DispScDrawer(vxydrw, title, dopt, "", 0, fglock);
[1525]1679
1680return;
1681
1682#endif
1683}
1684
[165]1685/* --Methode--
[331]1686void NamedObjMgr::DisplayImage(string& nom, string dopt)
[165]1687{
1688 cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
1689}
1690*/
1691
1692
1693
1694
[1971]1695/* --Methode--
[165]1696void NamedObjMgr::SetGraphicAttributes(string gratt)
1697{
1698bool fg = false;
1699servnobjm->DecodeDispOption(gratt, fg);
[546]1700Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
[165]1701}
[333]1702
[165]1703void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
1704{
1705if (!myImgApp) return;
1706if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
1707else myImgApp->SetZone(nzx, nzy);
1708}
[1971]1709*/
[165]1710
1711/* --Methode-- */
[333]1712void NamedObjMgr::AddWRsId(string & nom, int wrsid)
[165]1713{
[333]1714if(wrsid != 0) {
1715 NObjList::iterator it = myObjs->find(nom);
1716 if (it == myObjs->end()) return;
1717 (*it).second.wrsid.push_back(wrsid);
[295]1718 }
[165]1719return;
1720}
1721
1722/* --Methode-- */
[333]1723void NamedObjMgr::UpdateObjMgrWindow(int did)
[165]1724{
[333]1725if (!myImgApp) return;
[2757]1726//RZDEL ZSync zs(*myMutex); zs.NOp();
[2492]1727if ( !_fgimgapp ) myImgApp->LockMutex();
[2490]1728
[685]1729(myImgApp->ObjMgrW())->ClearObjList();
[165]1730
[333]1731NObjList::iterator it;
1732string cn;
1733for(it = myObjs->begin(); it != myObjs->end(); it++) {
1734 if ((*it).second.dirid != did) continue;
1735 cn = (*it).first.substr(1);
[1321]1736 // cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
1737 cn = cn.substr(cn.find('/')+1) + " (T= " + (*it).second.obja->GetDataObjType() + ")" ;
[685]1738 (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
[165]1739 }
[2492]1740
1741if ( !_fgimgapp ) myImgApp->UnlockMutex(true);
[333]1742}
[165]1743
1744
[333]1745/* Nouvelle-Fonction */
[1207]1746void NamedObjMgr::RemoveSpacesFromName(string & nom)
[165]1747{
[333]1748// on supprime les blancs de debut et de fin
1749size_t p = nom.find_first_not_of(" ");
1750if(p>nom.length()) { nom = ""; return; }
1751nom = nom.substr(p);
1752p = nom.find(' ');
1753if(p>nom.length()) p=nom.length();
1754nom = nom.substr(0, p);
[165]1755}
1756
[333]1757/* Nouvelle-Fonction */
[1207]1758bool NamedObjMgr::CheckDirName(string & nom)
[165]1759{
[333]1760RemoveSpacesFromName(nom);
1761if (nom.length() < 1) return(false);
1762if (nom[0] == '/') nom = nom.substr(1) ;
1763size_t p = nom.find('/');
1764if (p < nom.length()) nom = nom.substr(0,p);
[2218]1765if ((nom.length() < 1) || (! isalpha(nom[0]) ) ) return(false);
[333]1766return(true);
[165]1767}
1768
[333]1769/* Nouvelle-Fonction */
[1207]1770int NamedObjMgr::ParseObjectName(string & nom, string & nomrep, string & nomobj)
[165]1771{
[333]1772RemoveSpacesFromName(nom);
1773// Si le nom ne commence pas par un slash, c'est le repertoire courant
1774if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
[165]1775else {
[333]1776 string xx = nom.substr(1);
1777 size_t p = xx.find('/');
1778 if (p < xx.length()) {
1779 nomrep = xx.substr(0,p);
1780 nomobj = xx.substr(p+1);
[165]1781 }
[333]1782 else {
1783 nomrep = xx;
1784 nomobj = "";
[165]1785 }
1786 }
[333]1787int rc = 0;
1788NObjDirList::iterator it = myDirs->find(nomrep);
1789if (it != myDirs->end()) rc = (*it).second.id;
1790return(rc);
[165]1791}
1792
Note: See TracBrowser for help on using the repository browser.