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

Last change on this file since 685 was 685, checked in by ercodmgr, 26 years ago

FileChooser multiples ds PIStdImgApp, Correction Ndisp ds PINTuple, Fenetre NObjMgrWind non bloquant desormais ds piapp - Reza 12/12/99

File size: 35.4 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4
5#include <typeinfo>
6#include <iostream.h>
7#include <string>
8#include <list>
9#include <map>
10
11#include "strutil.h"
12#include "datatypes.h"
13
14#include "nobjmgr.h"
15#include "servnobjm.h"
16#include "nomgadapter.h"
17#include "pistdimgapp.h"
18
19
20// EVOL-PLANCK
21#ifdef SANS_EVOLPLANCK
22#include "fitsimage.h"
23#endif
24
25#include "pisurfdr.h"
26#include "pipodrw.h"
27
28#include "pintuple.h"
29#include "pintup3d.h"
30#include "pigfd1.h"
31#include "pigfd2.h"
32
33
34//++
35// Class NamedObjMgr
36// Lib PI
37// include nobjmgr.h
38//
39// Cette classe fournit les services nécéssaires à la gestion des objets
40// (l'ensemble des objets PPersist de PEIDA++) au sein du programme
41// d'analyse interactive *piapp* . Elle constitue en outre l'interface
42// entre les fonctions utilisateur et l'application graphique.
43//--
44//++
45// Links Voir aussi
46// PIStdImgApp
47// Services2NObjMgr
48// PIACmd
49//--
50
51
52// ..................................................................
53// ...... Gestion des objets nommes, variables globales ............
54struct nobj_diritem {
55 int id; // Directory Id
56 int nobj; // Number of objects in directory
57 bool lock; // True -> directory locked, No Add, del or rename
58 bool keepold; // True -> When duplicate object name, old object moved to /old
59};
60
61typedef map<string, nobj_diritem, less<string> > NObjDirList;
62
63struct nobj_item {
64 AnyDataObj* obj; // Object pointer
65 NObjMgrAdapter* obja; // Object adapter pointer
66 int oid; // object Id
67 int dirid; // Directory Id
68 list<int> wrsid; // List of Window Resource Id (Drawer, PIBaseWdg, ...)
69 // (for PIStdImgApp)
70 bool operator==(nobj_item const& b) const
71 { return (this->obj == b.obj); }
72};
73
74typedef map<string, nobj_item, less<string> > NObjList;
75
76static NObjDirList* myDirs = NULL;
77static NObjList* myObjs = NULL;
78static int fgOInit = 0;
79static int myNObj = 0;
80static int myDirId = 0;
81static string* currDir;
82
83static PIStdImgApp* myImgApp=NULL;
84static Services2NObjMgr* servnobjm=NULL;
85
86static string* TmpDir; // Repertoire pour les compilations / link dynamique
87
88
89// Pour completer le nom de l'objet avec le nom du repertoire
90static void RemoveSpacesFromName(string & nom);
91static bool CheckDirName(string & nom);
92static int ParseObjectName(string & nom, string & nomrep, string & nomobj);
93// ..................................................................
94
95//++
96// Titre Constructeurs
97//--
98//++
99// NamedObjMgr()
100// Constructeur. Les différents instantiation de la classe "NamedObjMgr"
101// dans une même application créent des objets qui travaillent sur la même
102// liste d'objets. Les objets de cette classe ne possedent en effet pas
103// de variables membres.
104//--
105
106/* --Methode-- */
107NamedObjMgr::NamedObjMgr()
108{
109if (fgOInit == 0) {
110 myNObj = 0;
111 myDirId = 0;
112 myDirs = new NObjDirList;
113 myObjs = new NObjList;
114 currDir = new string("home");
115 string dirn = "home";
116 CreateDir(dirn);
117 SetKeepOldDirAtt(dirn, true);
118 dirn = "tmp";
119 CreateDir(dirn);
120 SetKeepOldDirAtt(dirn, false);
121 dirn = "autoc";
122 CreateDir(dirn);
123 SetKeepOldDirAtt(dirn, false);
124 dirn = "old";
125 CreateDir(dirn);
126 SetKeepOldDirAtt(dirn, false);
127 dirn = "home";
128 SetCurrentDir(dirn);
129 myDirId = 50;
130 char* varenv;
131 TmpDir = new string("");
132 if ( (varenv=getenv("PEIDA_TMP")) != NULL ) (*TmpDir) = varenv;
133 else if ( (varenv=getenv("TMPDIR")) != NULL ) (*TmpDir) = varenv;
134 int l = (*TmpDir).length();
135 if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
136 servnobjm = new Services2NObjMgr(this, (*TmpDir));
137 }
138fgOInit++;
139}
140
141
142/* --Methode-- */
143NamedObjMgr::~NamedObjMgr()
144{
145fgOInit--;
146if (fgOInit == 0) delete myObjs;
147}
148
149//++
150// Titre Méthodes
151//--
152//++
153// void SetImgApp(PIStdImgApp* app)
154// Spécifie l'objet "PIStdImgApp" associé.
155// PIStdImgApp* GetImgApp()
156// Accès à l'objet "PIStdImgApp" associé.
157//--
158
159/* --Methode-- */
160void NamedObjMgr::SetImgApp(PIStdImgApp* app)
161{
162myImgApp = app;
163servnobjm->SetImgApp(app);
164
165NObjDirList::iterator it;
166string cn;
167for(it= myDirs->begin(); it != myDirs->end(); it++) {
168 cn = '/' + (*it).first;
169 (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
170 }
171}
172
173
174static bool verbeux = false; // true -> plus de message (creation/suppression d'objets)
175void NamedObjMgr::SetVerbose(bool fg)
176{
177verbeux = fg;
178}
179
180/* --Methode-- */
181PIStdImgApp* NamedObjMgr::GetImgApp()
182{
183return(myImgApp);
184}
185
186/* --Methode-- */
187Services2NObjMgr* NamedObjMgr::GetServiceObj()
188{
189return(servnobjm);
190}
191
192/* --Methode-- */
193bool NamedObjMgr::CreateDir(string & dirname)
194{
195if ( !CheckDirName(dirname) ) {
196 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
197 return(false);
198 }
199NObjDirList::iterator it = myDirs->find(dirname);
200if (it != myDirs->end()) {
201 cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
202 return(false);
203 }
204myDirId++;
205nobj_diritem di;
206di.id = myDirId;
207di.nobj = 0;
208di.lock = false;
209di.keepold = false;
210(*myDirs)[dirname] = di;
211if (myImgApp) {
212 string str = '/' + dirname;
213 (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
214 }
215if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
216return(true);
217}
218
219/* --Methode-- */
220bool NamedObjMgr::DeleteDir(string & dirname)
221{
222if ( !CheckDirName(dirname) ) {
223 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
224 return(false);
225 }
226NObjDirList::iterator it = myDirs->find(dirname);
227if (it == myDirs->end()) {
228 cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
229 return(false);
230 }
231if ((*it).second.nobj > 0) {
232 cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
233 return(false);
234 }
235if ((*it).second.lock ) {
236 cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
237 return(false);
238 }
239if ((*it).second.id < 50) {
240 cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
241 return(false);
242 }
243
244if (myImgApp)
245 (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
246myDirs->erase(it);
247if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;
248return(true);
249}
250
251/* --Methode-- */
252void NamedObjMgr::LockDir(string & dirname)
253{
254if ( !CheckDirName(dirname) ) return;
255NObjDirList::iterator it = myDirs->find(dirname);
256if (it == myDirs->end()) return;
257(*it).second.lock = true;
258if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
259return;
260}
261
262/* --Methode-- */
263void NamedObjMgr::UnlockDir(string & dirname)
264{
265if ( !CheckDirName(dirname) ) return;
266NObjDirList::iterator it = myDirs->find(dirname);
267if (it == myDirs->end()) return;
268(*it).second.lock = true;
269if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
270return;
271}
272
273/* --Methode-- */
274void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold)
275{
276if ( !CheckDirName(dirname) ) return;
277NObjDirList::iterator it = myDirs->find(dirname);
278if (it == myDirs->end()) return;
279(*it).second.keepold = keepold;
280if (!verbeux) return;
281cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << " -> ";
282if ( keepold ) cout << " True " << endl;
283else cout << " False " << endl;
284return;
285}
286
287
288/* --Methode-- */
289bool NamedObjMgr::SetCurrentDir(string & dirname)
290{
291if ( !CheckDirName(dirname) ) {
292 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
293 return(false);
294 }
295NObjDirList::iterator it = myDirs->find(dirname);
296if (it == myDirs->end()) {
297 cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
298 return(false);
299 }
300*currDir = dirname;
301if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
302return(true);
303}
304
305/* --Methode-- */
306void NamedObjMgr::GetCurrentDir(string & dirname)
307{
308dirname = *currDir;
309}
310
311/* --Methode-- */
312void NamedObjMgr::ListDirs(string & patt)
313{
314NObjDirList::iterator it;
315string cn;
316cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
317int k = 0;
318for(it= myDirs->begin(); it != myDirs->end(); it++) {
319 cn = (*it).first;
320 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
321 k++;
322 cout << k << "- " << (*it).first;
323 if ( (*it).second.lock ) cout << " Locked " ;
324 if ( (*it).second.keepold ) cout << " KeepOld " ;
325 cout << " (Id= " << (*it).second.id << " NbObj= " << (*it).second.nobj << ")" << endl;
326
327 }
328}
329
330/* --Methode-- */
331void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
332{
333NObjDirList::iterator it;
334string cn;
335for(it= myDirs->begin(); it != myDirs->end(); it++) {
336 cn = (*it).first;
337 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
338 lstd.push_back(cn);
339 }
340}
341
342/* --Methode-- */
343void NamedObjMgr::CleanDir(string & dirname)
344{
345if ( !CheckDirName(dirname) ) {
346 cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
347 // return(false); $CHECK$ illegal return value in void function
348 }
349NObjDirList::iterator itr = myDirs->find(dirname);
350if (itr == myDirs->end()) {
351 cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
352 // return(false); $CHECK$ illegal return value in void function
353 }
354
355int did = (*itr).second.id;
356NObjList::iterator it;
357list<int>::iterator iwr;
358bool nodisp = true;
359list<string> odel;
360for(it = myObjs->begin(); it != myObjs->end(); it++) {
361 if ((*it).second.dirid != did) continue;
362 nodisp = true;
363 if (myImgApp)
364 for(iwr=(*it).second.wrsid.begin(); iwr != (*it).second.wrsid.end(); iwr++)
365 if (myImgApp->CheckWRsId(*iwr)) { nodisp = false; break; }
366 if (nodisp) odel.push_back((*it).first);
367 }
368list<string>::iterator ii;
369for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii,true);
370if (myImgApp)
371 (myImgApp->ObjMgrW())->UpdateList(did);
372}
373
374
375
376//++
377// Titre Gestion de la liste des objets
378//--
379//++
380// void AddObj(AnyDataObj* obj, string& nom)
381// Ajoute l'objet "obj" à la liste, identifié par "nom".
382// Si un objet de même nom existe, l'ancien objet est renommé en concaténant
383// un numéro à son nom.
384// void DelObj(string const& nom, bool fgd=true)
385// Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
386// void DelObjects(string const& patt, bool fgd=true)
387// Supprime l'ensemble des objets dont le nom correspond au patron "patt".
388// Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
389// AnyDataObj* GetObj(string const& nom)
390// Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
391// pas dans la liste.
392// void RenameObj(string const& nom, string& nomnew)
393// Change le nom d'un objet dans la liste.
394// void CopyObj(string const& nom, string& nomcp)
395// Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
396//--
397
398
399/* --Methode-- */
400bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
401{
402
403if (obj == NULL) return(false);
404// On verifie si l'objet est deja dans la liste
405NObjList::iterator it;
406for(it = myObjs->begin(); it != myObjs->end(); it++) {
407 if ((*it).second.obj == obj) {
408 cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
409 return(false);
410 }
411 }
412string nobj;
413string nrep;
414char buff[32];
415int did = ParseObjectName(nom, nrep, nobj);
416if (did == 0) {
417 if (!crd) {
418 cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
419 return(false);
420 }
421 else { CreateDir(nrep); did = myDirId; }
422 }
423
424// Si c'est le repertoire /autoc, on nettoie
425if (nrep == "autoc") {
426 CleanDir(nrep);
427 }
428
429myNObj++;
430if (nobj.length() < 1) {
431 sprintf(buff,"O%d", myNObj);
432 nobj = buff;
433 }
434
435nom = '/' + nrep + '/' + nobj;
436NObjDirList::iterator itr = myDirs->find(nrep);
437if ((*itr).second.lock) {
438 cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
439 return(false);
440 }
441it = myObjs->find(nom);
442if (it != myObjs->end()) { // l'objet existe deja
443 if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
444 sprintf(buff, "%d", (*it).second.oid);
445 string nomnew = "/autoc/" + nobj + buff;
446 RenameObj(nom, nomnew);
447 }
448 else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
449 string on,od;
450// ParseObjectName((*it).first, od, on);
451 sprintf(buff, "%d", (*it).second.oid);
452 string nomnew = "/old/" + nobj + buff;
453 RenameObj(nom, nomnew);
454 }
455 else { // Sinon, on remplace l'objet
456 cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
457 DelObj(nom);
458 }
459 }
460
461nobj_item no;
462no.obj = obj;
463no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
464no.oid = myNObj;
465no.dirid = did;
466(*myObjs)[nom] = no;
467
468(*itr).second.nobj++;
469
470if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
471 string oln = nobj + " (T= " + typeid(*obj).name() + ")" ;
472 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
473 }
474if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
475 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
476return(true);
477}
478
479/* --Methode-- */
480bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
481{
482string n1,r1,n2,r2;
483int dids = ParseObjectName(nom, r1, n1);
484NObjDirList::iterator itr1 = myDirs->find(r1);
485int did = ParseObjectName(nomnew, r2, n2);
486NObjDirList::iterator itr2 = myDirs->find(r2);
487
488if (did == 0) {
489 cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
490 return(false);
491 }
492nom = '/' + r1 + '/' + n1;
493nomnew = '/' + r2 + '/' + n2;
494NObjList::iterator it1 = myObjs->find(nom);
495if (it1 == myObjs->end()) {
496 cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl;
497 return(false);
498 }
499NObjList::iterator it2 = myObjs->find(nomnew);
500if (it2 != myObjs->end()) {
501 cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
502 return(false);
503 }
504
505if ( (*itr1).second.lock || (*itr2).second.lock ) {
506 cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !"
507 << endl;
508 return(false);
509 }
510
511
512nobj_item no = (*it1).second;
513no.dirid = did;
514myObjs->erase(it1);
515NObjDirList::iterator itr = myDirs->find(r1);
516(*itr).second.nobj--;
517(*myObjs)[nomnew] = no;
518itr = myDirs->find(r2);
519(*itr).second.nobj++;
520
521if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
522 (myImgApp->ObjMgrW())->DelObjList(dids, no.oid);
523 string oln = n2 + " (T= " + typeid(*(no.obj)).name() + ")" ;
524 (myImgApp->ObjMgrW())->AddObjList(did, oln.c_str(), no.oid);
525}
526if (verbeux)
527 cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
528return(true);
529}
530
531/* --Methode-- */
532bool NamedObjMgr::CopyObj(string & nom, string& nomcp)
533{
534if(nomcp.length()<=0)
535 {cout<<"NamedObjMgr::CopyObj() Error, copied obj name "<<nomcp<<" not valid"<<endl;
536 return(false);}
537NObjMgrAdapter* obnom = GetObjAdapter(nom);
538if(obnom==NULL)
539 {cout<<"NamedObjMgr::CopyObj() Error - No "<<nom<<" object !"<<endl;
540 return(false);}
541AnyDataObj* obnomcp = obnom->GetCopyObj();
542if(obnomcp==NULL) return(false);
543if(! AddObj(obnomcp,nomcp) ) {delete obnomcp; return(false);}
544return true;
545}
546
547/* --Methode-- */
548bool NamedObjMgr::DelObj(string & nom, bool fgd)
549{
550string n1,r1;
551int did = ParseObjectName(nom, r1, n1);
552nom = '/' + r1 + '/' + n1;
553NObjList::iterator it = myObjs->find(nom);
554if (it == myObjs->end()) return(false);
555NObjDirList::iterator itr = myDirs->find(r1);
556if ( (*itr).second.lock ) {
557 cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
558 return(false);
559 }
560list<int>::iterator ii;
561if (myImgApp) {
562//DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
563 for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
564 myImgApp->DelWRsId((*ii));
565}
566delete (*it).second.obja; // destruction de l'adaptateur
567if (fgd) delete (*it).second.obj;
568
569if ( (myImgApp != NULL) && (myImgApp->ObjMgrW())->Visible() ) {
570 int olid = (*it).second.oid;
571 (myImgApp->ObjMgrW())->DelObjList(did, olid);
572}
573myObjs->erase(it);
574(*itr).second.nobj--;
575
576
577if (!verbeux) return(true);
578if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
579else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
580return(true);
581}
582
583/* --Methode-- */
584bool NamedObjMgr::DelObj_Id(int oid)
585{
586NObjList::iterator it;
587string nom;
588bool of = false;
589for(it = myObjs->begin(); it != myObjs->end(); it++)
590 if ( (*it).second.oid == oid ) {
591 of = true; nom = (*it).first;
592 break;
593 }
594if (of) return(DelObj(nom, true));
595else return(false);
596}
597
598/* --Methode-- */
599void NamedObjMgr::DelObjects(string & patt, bool fgd)
600{
601string n1,r1;
602ParseObjectName(patt, r1, n1);
603patt = '/' + r1 + '/' + n1;
604NObjList::iterator it;
605list<string> odel;
606string cn;
607for(it = myObjs->begin(); it != myObjs->end(); it++) {
608 cn = (*it).first;
609 if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
610 }
611list<string>::iterator ii;
612for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii, fgd);
613}
614
615/* --Methode-- */
616AnyDataObj* NamedObjMgr::GetObj(string & nom)
617{
618string n1,r1;
619ParseObjectName(nom, r1, n1);
620nom = '/' + r1 + '/' + n1;
621NObjList::iterator it = myObjs->find(nom);
622if (it == myObjs->end()) return(NULL);
623return((*it).second.obj);
624}
625
626/* --Methode-- */
627NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
628{
629string n1,r1;
630ParseObjectName(nom, r1, n1);
631nom = '/' + r1 + '/' + n1;
632NObjList::iterator it = myObjs->find(nom);
633if (it == myObjs->end()) return(NULL);
634return((*it).second.obja);
635}
636
637/* --Methode-- */
638void NamedObjMgr::ListObjs(string & patt)
639{
640int k;
641AnyDataObj* obj=NULL;
642string ctyp;
643char strg[256];
644
645string n1,r1;
646ParseObjectName(patt, r1, n1);
647patt = '/' + r1 + '/' + n1;
648 cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
649NObjList::iterator it; k = 0;
650string cn;
651for(it = myObjs->begin(); it != myObjs->end(); it++) {
652 cn = (*it).first;
653 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
654 obj = (*it).second.obj;
655 ctyp = typeid(*obj).name();
656 sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
657 ctyp = strg;
658 cout << ctyp << "\n" ;
659 k++;
660}
661cout << endl;
662return;
663}
664
665/* --Methode-- */
666void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
667{
668string n1,r1;
669if (patt.length() < 1) return;
670bool fgr = (patt[0] == '/') ? true : false;
671ParseObjectName(patt, r1, n1);
672patt = '/' + r1 + '/' + n1;
673NObjList::iterator it;
674string cn;
675for(it = myObjs->begin(); it != myObjs->end(); it++) {
676 cn = (*it).first;
677 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
678 if (fgr) lst.push_back(cn);
679 else {
680 ParseObjectName(cn, r1, n1);
681 lst.push_back(n1);
682 }
683 }
684}
685
686//++
687// Titre Entrées-Sorties (I/O) sur les objets
688//--
689//++
690// void ReadObj(PInPersist& s, int num=-1)
691// Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
692// et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
693// sur le flot "s" sont créés et ajoutés à la liste.
694// void ReadObj(string const & nomppf, string nobj="")
695// Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
696// à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
697// composé à partir du nom de fichier.
698//--
699
700/* --Methode-- */
701void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
702{
703PPersist* ppobj=NULL;
704bool ok = true;
705#ifdef SANS_EVOLPLANCK
706TRY{
707 PInPersist pis(flnm);
708 ppobj = PPersistMgr::ReadObject(pis);
709 if (ppobj == NULL) ok = false;
710} CATCH(merr)
711 { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
712 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
713#else
714try {
715 PInPersist pis(flnm);
716 ppobj = pis.ReadObject();
717 }
718catch (IOExc iox) {
719 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
720 ok = false;
721 }
722#endif
723if (!ok) return;
724if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
725AddObj(ppobj->DataObj(), nobj, true);
726cout << "NamedObjMgr::ReadObj(...) object " << nobj << " read from file " << endl;
727return;
728}
729
730/* --Methode-- */
731void NamedObjMgr::ReadObj(PInPersist& s, int num)
732{
733int_4 i, cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
734int n0, n1;
735bool ok = true;
736PPersist* obj=NULL;
737string nom;
738
739int nread = 0;
740if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
741 if (num >= 0) {
742 cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
743 << s.NbTags() << endl;
744 return;
745 }
746
747#ifdef SANS_EVOLPLANCK
748 TRY {
749 obj = PPersistMgr::ReadObject(s);
750 if (obj == NULL) ok = false;
751 } CATCH(merr) {
752 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
753 ok = false;
754 } ENDTRY;
755#else
756try {
757 obj = s.ReadObject();
758 }
759catch (IOExc iox) {
760 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
761 ok = false;
762 }
763#endif
764
765 if (!ok) return;
766 nom = "";
767 AddObj(obj->DataObj(), nom);
768 nread++;
769}
770
771if (num < 0) { n0 = 0; n1 = s.NbTags(); }
772else { n0 = num; n1 = num+1; }
773for(i=n0; i<n1; i++) {
774#ifdef SANS_EVOLPLANCK
775 key = s.TagKey(i, cid, ln);
776 if (ln <= 0) nom = "";
777 else nom = s.TagName(i);
778 s.GotoTag(i);
779 TRY {
780 obj = PPersistMgr::ReadObject(s);
781 if (obj == NULL) ok = false;
782 } CATCH(merr) {
783 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
784 ok = false;
785 } ENDTRY;
786#else
787 s.GotoTagNum(i);
788 nom = s.GetTagName(i);
789 try {
790 obj = s.ReadObject();
791 }
792 catch (IOExc iox) {
793 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
794 ok = false;
795 }
796#endif
797 if (ok) { AddObj(obj->DataObj(), nom, true); nread++; }
798}
799
800cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
801return;
802}
803/* --Methode-- */
804void NamedObjMgr::ReadAll(string const & flnm)
805{
806bool ok = true;
807PPersist* obj=NULL;
808
809PInPersist* ppin;
810#ifdef SANS_EVOLPLANCK
811TRY{
812 ppin = new PInPersist(flnm);
813 if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
814 else obj = NULL;
815} CATCH(merr)
816 { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
817 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
818#else
819try {
820 ppin = new PInPersist(flnm);
821 if (ppin->NbTags() < 1) obj = ppin->ReadObject();
822 else obj = NULL;
823}
824catch (IOExc iox) {
825 cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
826 ok = false;
827}
828#endif
829if (!ok) return;
830if (obj) {
831 string nom = servnobjm->FileName2Name(flnm);
832 AddObj(obj->DataObj(), nom);
833 }
834else ReadObj((*ppin), -1);
835delete ppin;
836return;
837}
838
839/* --Methode-- */
840void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
841{
842bool ok = true;
843#ifdef SANS_EVOLPLANCK
844RzImage* obj;
845#else
846//CMV_A_FAIRE RzImage* obj;
847#endif
848
849// obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
850#ifdef SANS_EVOLPLANCK
851TRY{
852 obj = RzReadFits((char*)flnm.c_str());
853 if (obj == NULL) ok = false;
854} CATCH(merr) {
855 printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
856 ok = false;
857} ENDTRY;
858if (ok) {
859 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
860 AddObj((AnyDataObj*)obj, nobj);
861}
862#else
863 printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n");
864#endif
865return;
866}
867
868
869static int key_for_write = 5000;
870/* --Methode-- */
871void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
872{
873if (nom.length() < 1) return;
874string nob,rep;
875ParseObjectName(nom, rep, nob);
876nom = '/' + rep + '/' + nob;
877NObjMgrAdapter* obja=NULL;
878string nomf = (keeppath) ? nom : nob;
879obja = GetObjAdapter(nom);
880if (obja == NULL) return;
881printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
882 nom.c_str(), typeid(*(obja->GetDataObj())).name());
883obja->SavePPF(s, nomf);
884return;
885}
886
887/* --Methode-- */
888void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
889{
890string n1,r1;
891if (patt.length() < 1) return;
892bool keeppath = (patt[0] == '/') ? true : false;
893ParseObjectName(patt, r1, n1);
894patt = '/' + r1 + '/' + n1;
895
896bool ok = true;
897POutPersist* pout;
898#ifdef SANS_EVOLPLANCK
899TRY{
900 pout = new POutPersist(flnm);
901} CATCH(merr)
902 { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
903 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
904#else
905try {
906 pout = new POutPersist(flnm);
907}
908catch (IOExc iox) {
909 cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
910 ok = false;
911}
912#endif
913if (!ok) return;
914NObjList::iterator it;
915string cn;
916for(it = myObjs->begin(); it != myObjs->end(); it++) {
917 cn = (*it).first;
918 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
919 SaveObj(cn, (*pout), keeppath);
920 }
921delete pout;
922return;
923}
924
925/* --Methode-- */
926void NamedObjMgr::SaveAll(string const& flnm)
927{
928bool ok = true;
929
930POutPersist* pout;
931#ifdef SANS_EVOLPLANCK
932TRY{
933 pout = new POutPersist(flnm);
934} CATCH(merr)
935 { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
936 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
937#else
938try {
939 pout = new POutPersist(flnm);
940}
941catch (IOExc iox) {
942 cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
943 ok = false;
944}
945#endif
946if (!ok) return;
947NObjList::iterator it;
948string no;
949for(it = myObjs->begin(); it != myObjs->end(); it++) {
950 no = (*it).first;
951 SaveObj(no, (*pout), true);
952 }
953delete pout;
954return;
955}
956
957/* --Methode-- */
958void NamedObjMgr::SaveFits(string& nom, string const & flnm)
959{
960NObjMgrAdapter* obja=NULL;
961obja = GetObjAdapter(nom);
962if (obja == NULL) return;
963obja->SaveFits(flnm);
964return;
965}
966
967
968
969/* --Methode-- */
970void NamedObjMgr::PrintObj(string& nom)
971{
972NObjMgrAdapter* obja=NULL;
973obja = GetObjAdapter(nom);
974if (obja == NULL) return;
975AnyDataObj* ob = obja->GetDataObj();
976if (ob == NULL) {
977 cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
978 return;
979 }
980string ctyp = typeid(*ob).name();
981cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
982obja->Print(cout);
983
984return;
985}
986
987/* --Methode-- */
988void NamedObjMgr::DisplayObj(string& nom, string dopt)
989{
990NObjMgrAdapter* obja=NULL;
991obja = GetObjAdapter(nom);
992if (obja == NULL) {
993 cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
994 return;
995}
996if (obja->GetDataObj() == NULL) {
997 cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
998 return;
999 }
1000if (!myImgApp) return;
1001
1002PIDrawer * dr = NULL;
1003P2DArrayAdapter* arr = NULL;
1004dr = obja->GetDrawer(dopt);
1005if (!dr) arr = obja->Get2DArray(dopt);
1006
1007if (!dr && !arr) {
1008 string ctyp = typeid(*(obja->GetDataObj())).name();
1009 cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
1010 return;
1011 }
1012
1013int wrsid = 0;
1014bool fgsr = true;
1015int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1016
1017string n1,r1;
1018ParseObjectName(nom, r1, n1);
1019
1020if (dr) {
1021 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
1022 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
1023 else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
1024 }
1025else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
1026
1027if(wrsid != 0) {
1028 NObjList::iterator it = myObjs->find(nom);
1029 if (it == myObjs->end()) return;
1030 (*it).second.wrsid.push_back(wrsid);
1031 }
1032if (fgsr) myImgApp->RestoreGraphicAtt();
1033return;
1034}
1035
1036/* --Methode-- */
1037void NamedObjMgr::DisplayImage(string& nom, string dopt)
1038{
1039NObjMgrAdapter* obja=NULL;
1040obja = GetObjAdapter(nom);
1041if (obja == NULL) {
1042 cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
1043 return;
1044}
1045if (obja->GetDataObj() == NULL) {
1046 cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
1047 return;
1048 }
1049if (!myImgApp) return;
1050
1051P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1052
1053if (!arr) {
1054 string ctyp = typeid(*(obja->GetDataObj())).name();
1055 cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
1056 return;
1057 }
1058
1059string n1,r1;
1060ParseObjectName(nom, r1, n1);
1061
1062int wrsid = 0;
1063bool fgsr = true;
1064int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1065wrsid = myImgApp->DispImage(arr, n1, opt);
1066
1067if(wrsid != 0) {
1068 NObjList::iterator it = myObjs->find(nom);
1069 if (it == myObjs->end()) return;
1070 (*it).second.wrsid.push_back(wrsid);
1071 }
1072if (fgsr) myImgApp->RestoreGraphicAtt();
1073return;
1074}
1075/* --Methode-- */
1076void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
1077{
1078NObjMgrAdapter* obja=NULL;
1079obja = GetObjAdapter(nom);
1080if (obja == NULL) {
1081 cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
1082 return;
1083}
1084if (obja->GetDataObj() == NULL) {
1085 cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
1086 return;
1087 }
1088if (!myImgApp) return;
1089
1090P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1091
1092if (!arr) {
1093 string ctyp = typeid(*(obja->GetDataObj())).name();
1094 cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
1095 return;
1096 }
1097
1098if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
1099 cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
1100 << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
1101 delete arr;
1102 return;
1103 }
1104
1105string n1,r1;
1106ParseObjectName(nom, r1, n1);
1107
1108int wrsid = 0;
1109bool fgsr = true;
1110int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1111PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
1112wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
1113if(wrsid >= 0) {
1114 NObjList::iterator it = myObjs->find(nom);
1115 if (it == myObjs->end()) return;
1116 (*it).second.wrsid.push_back(wrsid);
1117 }
1118
1119if (fgsr) myImgApp->RestoreGraphicAtt();
1120return;
1121}
1122
1123/* --Methode-- */
1124void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
1125 string& erx, string& ery, string& erz, string& wt,
1126 string& label, string dopt, bool fg3d)
1127{
1128AnyDataObj* obj=GetObj(nom);
1129if (obj == NULL) {
1130 cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
1131 return;
1132}
1133if (!myImgApp) return;
1134
1135NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
1136if (nt == NULL) {
1137// if (typeid(*obj) != typeid(NTupleInterface)) {
1138 string ctyp = typeid(*obj).name();
1139 cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
1140 return;
1141 }
1142
1143int wrsid = 0;
1144bool fgsr = true;
1145dopt = "defline," + dopt;
1146int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1147
1148string n1,r1;
1149ParseObjectName(nom, r1, n1);
1150
1151if ( fg3d && (nmz.length()>0) ) { // Display 3D
1152 PINTuple3D* pin = new PINTuple3D(nt, false);
1153 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
1154 pin->SelectWt(wt.c_str());
1155 pin->SelectLabel(label.c_str());
1156 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
1157 string titre = nmz + "%" + nmy + "%" + nmz;
1158 wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);
1159}
1160else {
1161 PINTuple* pin = new PINTuple(nt, false);
1162 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
1163 pin->SelectXY(nmx.c_str(), nmy.c_str());
1164 pin->SelectWt(wt.c_str());
1165 pin->SelectLabel(label.c_str());
1166 pin->SelectErrBar(erx.c_str(), ery.c_str());
1167 string titre = nmy + "%" + nmx;
1168 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
1169 }
1170
1171if(wrsid >= 0) {
1172 NObjList::iterator it = myObjs->find(nom);
1173 if (it == myObjs->end()) return;
1174 (*it).second.wrsid.push_back(wrsid);
1175 }
1176
1177if (fgsr) myImgApp->RestoreGraphicAtt();
1178return;
1179}
1180
1181/* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
1182void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
1183// Pour le display 2D ou 3D d'un ``GeneralFitData''.
1184//| nom = nom de l'objet GeneralFitData a representer.
1185//| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
1186//| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
1187//| Pour le display 2D, numvary="" string vide.
1188//| err = qu'elles erreurs faut il representer ?
1189//| - 2D : x y xy (display y=f(x))
1190//| - 3D : x y z xy xz yz xzy (display z=f(x,y))
1191//| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
1192//| les barres d'erreurs sont representees.
1193//| opt = options generales pour le display.
1194{
1195AnyDataObj* obj=GetObj(nom);
1196if(obj == NULL)
1197 {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
1198 return;}
1199if(!myImgApp) return;
1200if(typeid(*obj) != typeid(GeneralFitData))
1201 {string ctyp = typeid(*obj).name();
1202 cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
1203 return;}
1204
1205// Decodage des options classiques
1206bool fgsr = true;
1207int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1208// Decodage des erreurs a representer
1209bool errx=false, erry=false, errz=false;
1210if(err.length()>0) {
1211 for(int i=0;i<err.length();i++)
1212 if (err[i]=='x' || err[i]=='X') errx = true;
1213 else if(err[i]=='y' || err[i]=='Y') erry = true;
1214 else if(err[i]=='z' || err[i]=='Z') errz = true;
1215}
1216// Decodage des numeros de variables en abscisse
1217 int numvx=-1, numvy=-1;
1218 if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
1219 if(numvary.length()>0) numvy = atoi(numvary.c_str());
1220
1221 string n1,r1;
1222 ParseObjectName(nom, r1, n1);
1223
1224 int wrsid = 0;
1225 if(numvy>=0) { // display 3D
1226 PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
1227 pigfd->SelectXY(numvx,numvy);
1228 pigfd->SelectErrBar(errx,erry,errz);
1229 wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);
1230} else { // display 2D
1231 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
1232 pigfd->SelectX(numvx);
1233 pigfd->SelectErrBar(errx,erry);
1234 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
1235}
1236
1237if(wrsid >= 0) {
1238 NObjList::iterator it = myObjs->find(nom);
1239 if (it == myObjs->end()) return;
1240 (*it).second.wrsid.push_back(wrsid);
1241}
1242if (fgsr) myImgApp->RestoreGraphicAtt();
1243return;
1244}
1245
1246/* --Methode--
1247void NamedObjMgr::DisplayImage(string& nom, string dopt)
1248{
1249 cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
1250}
1251*/
1252
1253
1254
1255
1256/* --Methode-- */
1257void NamedObjMgr::SetGraphicAttributes(string gratt)
1258{
1259bool fg = false;
1260servnobjm->DecodeDispOption(gratt, fg);
1261Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
1262}
1263
1264/* --Methode-- */
1265void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
1266{
1267if (!myImgApp) return;
1268if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
1269else myImgApp->SetZone(nzx, nzy);
1270}
1271
1272/* --Methode-- */
1273void NamedObjMgr::AddWRsId(string & nom, int wrsid)
1274{
1275if(wrsid != 0) {
1276 NObjList::iterator it = myObjs->find(nom);
1277 if (it == myObjs->end()) return;
1278 (*it).second.wrsid.push_back(wrsid);
1279 }
1280return;
1281}
1282
1283/* --Methode-- */
1284void NamedObjMgr::UpdateObjMgrWindow(int did)
1285{
1286if (!myImgApp) return;
1287(myImgApp->ObjMgrW())->ClearObjList();
1288
1289NObjList::iterator it;
1290string cn;
1291for(it = myObjs->begin(); it != myObjs->end(); it++) {
1292 if ((*it).second.dirid != did) continue;
1293 cn = (*it).first.substr(1);
1294 cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
1295 (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
1296 }
1297}
1298
1299
1300/* Nouvelle-Fonction */
1301void RemoveSpacesFromName(string & nom)
1302{
1303// on supprime les blancs de debut et de fin
1304size_t p = nom.find_first_not_of(" ");
1305if(p>nom.length()) { nom = ""; return; }
1306nom = nom.substr(p);
1307p = nom.find(' ');
1308if(p>nom.length()) p=nom.length();
1309nom = nom.substr(0, p);
1310}
1311
1312/* Nouvelle-Fonction */
1313bool CheckDirName(string & nom)
1314{
1315RemoveSpacesFromName(nom);
1316if (nom.length() < 1) return(false);
1317if (nom[0] == '/') nom = nom.substr(1) ;
1318size_t p = nom.find('/');
1319if (p < nom.length()) nom = nom.substr(0,p);
1320if (nom.length() < 1) return(false);
1321return(true);
1322}
1323
1324/* Nouvelle-Fonction */
1325int ParseObjectName(string & nom, string & nomrep, string & nomobj)
1326{
1327RemoveSpacesFromName(nom);
1328// Si le nom ne commence pas par un slash, c'est le repertoire courant
1329if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
1330else {
1331 string xx = nom.substr(1);
1332 size_t p = xx.find('/');
1333 if (p < xx.length()) {
1334 nomrep = xx.substr(0,p);
1335 nomobj = xx.substr(p+1);
1336 }
1337 else {
1338 nomrep = xx;
1339 nomobj = "";
1340 }
1341 }
1342int rc = 0;
1343NObjDirList::iterator it = myDirs->find(nomrep);
1344if (it != myDirs->end()) rc = (*it).second.id;
1345return(rc);
1346}
1347
Note: See TracBrowser for help on using the repository browser.