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

Last change on this file since 1134 was 1105, checked in by ercodmgr, 25 years ago

Minimum pour compil de PIext suite Heritage classe Image<T> de TMatrix<T> Reza+CMV 27/7/2000

File size: 35.3 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 = false;
843
844#ifdef SANS_EVOLPLANCK
845RzImage* obj=NULL;
846TRY{
847 obj = RzReadFits((char*)flnm.c_str());
848 if (obj == NULL) ok = false;
849 else ok = true;
850} CATCH(merr) {
851 printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
852 ok = false;
853} ENDTRY;
854
855if (ok && (obj != NULL)) {
856 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
857 AddObj((AnyDataObj*)obj, nobj);
858}
859#else
860 cerr << " NamedObjMgr::ReadFits() Vide ! A faire Reza ! " << endl;
861#endif
862
863return;
864}
865
866
867static int key_for_write = 5000;
868/* --Methode-- */
869void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
870{
871if (nom.length() < 1) return;
872string nob,rep;
873ParseObjectName(nom, rep, nob);
874nom = '/' + rep + '/' + nob;
875NObjMgrAdapter* obja=NULL;
876string nomf = (keeppath) ? nom : nob;
877obja = GetObjAdapter(nom);
878if (obja == NULL) return;
879printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
880 nom.c_str(), typeid(*(obja->GetDataObj())).name());
881obja->SavePPF(s, nomf);
882return;
883}
884
885/* --Methode-- */
886void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
887{
888string n1,r1;
889if (patt.length() < 1) return;
890bool keeppath = (patt[0] == '/') ? true : false;
891ParseObjectName(patt, r1, n1);
892patt = '/' + r1 + '/' + n1;
893
894bool ok = true;
895POutPersist* pout;
896#ifdef SANS_EVOLPLANCK
897TRY{
898 pout = new POutPersist(flnm);
899} CATCH(merr)
900 { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
901 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
902#else
903try {
904 pout = new POutPersist(flnm);
905}
906catch (IOExc iox) {
907 cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
908 ok = false;
909}
910#endif
911if (!ok) return;
912NObjList::iterator it;
913string cn;
914for(it = myObjs->begin(); it != myObjs->end(); it++) {
915 cn = (*it).first;
916 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
917 SaveObj(cn, (*pout), keeppath);
918 }
919delete pout;
920return;
921}
922
923/* --Methode-- */
924void NamedObjMgr::SaveAll(string const& flnm)
925{
926bool ok = true;
927
928POutPersist* pout;
929#ifdef SANS_EVOLPLANCK
930TRY{
931 pout = new POutPersist(flnm);
932} CATCH(merr)
933 { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
934 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
935#else
936try {
937 pout = new POutPersist(flnm);
938}
939catch (IOExc iox) {
940 cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
941 ok = false;
942}
943#endif
944if (!ok) return;
945NObjList::iterator it;
946string no;
947for(it = myObjs->begin(); it != myObjs->end(); it++) {
948 no = (*it).first;
949 SaveObj(no, (*pout), true);
950 }
951delete pout;
952return;
953}
954
955/* --Methode-- */
956void NamedObjMgr::SaveFits(string& nom, string const & flnm)
957{
958NObjMgrAdapter* obja=NULL;
959obja = GetObjAdapter(nom);
960if (obja == NULL) return;
961obja->SaveFits(flnm);
962return;
963}
964
965
966
967/* --Methode-- */
968void NamedObjMgr::PrintObj(string& nom)
969{
970NObjMgrAdapter* obja=NULL;
971obja = GetObjAdapter(nom);
972if (obja == NULL) return;
973AnyDataObj* ob = obja->GetDataObj();
974if (ob == NULL) {
975 cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
976 return;
977 }
978string ctyp = typeid(*ob).name();
979cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
980obja->Print(cout);
981
982return;
983}
984
985/* --Methode-- */
986void NamedObjMgr::DisplayObj(string& nom, string dopt)
987{
988NObjMgrAdapter* obja=NULL;
989obja = GetObjAdapter(nom);
990if (obja == NULL) {
991 cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
992 return;
993}
994if (obja->GetDataObj() == NULL) {
995 cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
996 return;
997 }
998if (!myImgApp) return;
999
1000PIDrawer * dr = NULL;
1001P2DArrayAdapter* arr = NULL;
1002dr = obja->GetDrawer(dopt);
1003if (!dr) arr = obja->Get2DArray(dopt);
1004
1005if (!dr && !arr) {
1006 string ctyp = typeid(*(obja->GetDataObj())).name();
1007 cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
1008 return;
1009 }
1010
1011int wrsid = 0;
1012bool fgsr = true;
1013int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1014
1015string n1,r1;
1016ParseObjectName(nom, r1, n1);
1017
1018if (dr) {
1019 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
1020 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
1021 else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
1022 }
1023else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
1024
1025if(wrsid != 0) {
1026 NObjList::iterator it = myObjs->find(nom);
1027 if (it == myObjs->end()) return;
1028 (*it).second.wrsid.push_back(wrsid);
1029 }
1030if (fgsr) myImgApp->RestoreGraphicAtt();
1031return;
1032}
1033
1034/* --Methode-- */
1035void NamedObjMgr::DisplayImage(string& nom, string dopt)
1036{
1037NObjMgrAdapter* obja=NULL;
1038obja = GetObjAdapter(nom);
1039if (obja == NULL) {
1040 cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
1041 return;
1042}
1043if (obja->GetDataObj() == NULL) {
1044 cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
1045 return;
1046 }
1047if (!myImgApp) return;
1048
1049P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1050
1051if (!arr) {
1052 string ctyp = typeid(*(obja->GetDataObj())).name();
1053 cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
1054 return;
1055 }
1056
1057string n1,r1;
1058ParseObjectName(nom, r1, n1);
1059
1060int wrsid = 0;
1061bool fgsr = true;
1062int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1063wrsid = myImgApp->DispImage(arr, n1, opt);
1064
1065if(wrsid != 0) {
1066 NObjList::iterator it = myObjs->find(nom);
1067 if (it == myObjs->end()) return;
1068 (*it).second.wrsid.push_back(wrsid);
1069 }
1070if (fgsr) myImgApp->RestoreGraphicAtt();
1071return;
1072}
1073/* --Methode-- */
1074void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
1075{
1076NObjMgrAdapter* obja=NULL;
1077obja = GetObjAdapter(nom);
1078if (obja == NULL) {
1079 cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
1080 return;
1081}
1082if (obja->GetDataObj() == NULL) {
1083 cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
1084 return;
1085 }
1086if (!myImgApp) return;
1087
1088P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1089
1090if (!arr) {
1091 string ctyp = typeid(*(obja->GetDataObj())).name();
1092 cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
1093 return;
1094 }
1095
1096if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
1097 cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
1098 << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
1099 delete arr;
1100 return;
1101 }
1102
1103string n1,r1;
1104ParseObjectName(nom, r1, n1);
1105
1106int wrsid = 0;
1107bool fgsr = true;
1108int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1109PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
1110wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
1111if(wrsid >= 0) {
1112 NObjList::iterator it = myObjs->find(nom);
1113 if (it == myObjs->end()) return;
1114 (*it).second.wrsid.push_back(wrsid);
1115 }
1116
1117if (fgsr) myImgApp->RestoreGraphicAtt();
1118return;
1119}
1120
1121/* --Methode-- */
1122void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
1123 string& erx, string& ery, string& erz, string& wt,
1124 string& label, string dopt, bool fg3d)
1125{
1126AnyDataObj* obj=GetObj(nom);
1127if (obj == NULL) {
1128 cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
1129 return;
1130}
1131if (!myImgApp) return;
1132
1133NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
1134if (nt == NULL) {
1135// if (typeid(*obj) != typeid(NTupleInterface)) {
1136 string ctyp = typeid(*obj).name();
1137 cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
1138 return;
1139 }
1140
1141int wrsid = 0;
1142bool fgsr = true;
1143dopt = "defline," + dopt;
1144int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1145
1146string n1,r1;
1147ParseObjectName(nom, r1, n1);
1148
1149if ( fg3d && (nmz.length()>0) ) { // Display 3D
1150 PINTuple3D* pin = new PINTuple3D(nt, false);
1151 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
1152 pin->SelectWt(wt.c_str());
1153 pin->SelectLabel(label.c_str());
1154 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
1155 string titre = nmz + "%" + nmy + "%" + nmz;
1156 wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);
1157}
1158else {
1159 PINTuple* pin = new PINTuple(nt, false);
1160 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
1161 pin->SelectXY(nmx.c_str(), nmy.c_str());
1162 pin->SelectWt(wt.c_str());
1163 pin->SelectLabel(label.c_str());
1164 pin->SelectErrBar(erx.c_str(), ery.c_str());
1165 string titre = nmy + "%" + nmx;
1166 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
1167 }
1168
1169if(wrsid >= 0) {
1170 NObjList::iterator it = myObjs->find(nom);
1171 if (it == myObjs->end()) return;
1172 (*it).second.wrsid.push_back(wrsid);
1173 }
1174
1175if (fgsr) myImgApp->RestoreGraphicAtt();
1176return;
1177}
1178
1179/* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
1180void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
1181// Pour le display 2D ou 3D d'un ``GeneralFitData''.
1182//| nom = nom de l'objet GeneralFitData a representer.
1183//| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
1184//| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
1185//| Pour le display 2D, numvary="" string vide.
1186//| err = qu'elles erreurs faut il representer ?
1187//| - 2D : x y xy (display y=f(x))
1188//| - 3D : x y z xy xz yz xzy (display z=f(x,y))
1189//| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
1190//| les barres d'erreurs sont representees.
1191//| opt = options generales pour le display.
1192{
1193AnyDataObj* obj=GetObj(nom);
1194if(obj == NULL)
1195 {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
1196 return;}
1197if(!myImgApp) return;
1198if(typeid(*obj) != typeid(GeneralFitData))
1199 {string ctyp = typeid(*obj).name();
1200 cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
1201 return;}
1202
1203// Decodage des options classiques
1204bool fgsr = true;
1205int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1206// Decodage des erreurs a representer
1207bool errx=false, erry=false, errz=false;
1208if(err.length()>0) {
1209 for(int i=0;i<err.length();i++)
1210 if (err[i]=='x' || err[i]=='X') errx = true;
1211 else if(err[i]=='y' || err[i]=='Y') erry = true;
1212 else if(err[i]=='z' || err[i]=='Z') errz = true;
1213}
1214// Decodage des numeros de variables en abscisse
1215 int numvx=-1, numvy=-1;
1216 if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
1217 if(numvary.length()>0) numvy = atoi(numvary.c_str());
1218
1219 string n1,r1;
1220 ParseObjectName(nom, r1, n1);
1221
1222 int wrsid = 0;
1223 if(numvy>=0) { // display 3D
1224 PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
1225 pigfd->SelectXY(numvx,numvy);
1226 pigfd->SelectErrBar(errx,erry,errz);
1227 wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);
1228} else { // display 2D
1229 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
1230 pigfd->SelectX(numvx);
1231 pigfd->SelectErrBar(errx,erry);
1232 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
1233}
1234
1235if(wrsid >= 0) {
1236 NObjList::iterator it = myObjs->find(nom);
1237 if (it == myObjs->end()) return;
1238 (*it).second.wrsid.push_back(wrsid);
1239}
1240if (fgsr) myImgApp->RestoreGraphicAtt();
1241return;
1242}
1243
1244/* --Methode--
1245void NamedObjMgr::DisplayImage(string& nom, string dopt)
1246{
1247 cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
1248}
1249*/
1250
1251
1252
1253
1254/* --Methode-- */
1255void NamedObjMgr::SetGraphicAttributes(string gratt)
1256{
1257bool fg = false;
1258servnobjm->DecodeDispOption(gratt, fg);
1259Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
1260}
1261
1262/* --Methode-- */
1263void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
1264{
1265if (!myImgApp) return;
1266if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
1267else myImgApp->SetZone(nzx, nzy);
1268}
1269
1270/* --Methode-- */
1271void NamedObjMgr::AddWRsId(string & nom, int wrsid)
1272{
1273if(wrsid != 0) {
1274 NObjList::iterator it = myObjs->find(nom);
1275 if (it == myObjs->end()) return;
1276 (*it).second.wrsid.push_back(wrsid);
1277 }
1278return;
1279}
1280
1281/* --Methode-- */
1282void NamedObjMgr::UpdateObjMgrWindow(int did)
1283{
1284if (!myImgApp) return;
1285(myImgApp->ObjMgrW())->ClearObjList();
1286
1287NObjList::iterator it;
1288string cn;
1289for(it = myObjs->begin(); it != myObjs->end(); it++) {
1290 if ((*it).second.dirid != did) continue;
1291 cn = (*it).first.substr(1);
1292 cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
1293 (myImgApp->ObjMgrW())->AddObj(cn.c_str(), (*it).second.oid);
1294 }
1295}
1296
1297
1298/* Nouvelle-Fonction */
1299void RemoveSpacesFromName(string & nom)
1300{
1301// on supprime les blancs de debut et de fin
1302size_t p = nom.find_first_not_of(" ");
1303if(p>nom.length()) { nom = ""; return; }
1304nom = nom.substr(p);
1305p = nom.find(' ');
1306if(p>nom.length()) p=nom.length();
1307nom = nom.substr(0, p);
1308}
1309
1310/* Nouvelle-Fonction */
1311bool CheckDirName(string & nom)
1312{
1313RemoveSpacesFromName(nom);
1314if (nom.length() < 1) return(false);
1315if (nom[0] == '/') nom = nom.substr(1) ;
1316size_t p = nom.find('/');
1317if (p < nom.length()) nom = nom.substr(0,p);
1318if (nom.length() < 1) return(false);
1319return(true);
1320}
1321
1322/* Nouvelle-Fonction */
1323int ParseObjectName(string & nom, string & nomrep, string & nomobj)
1324{
1325RemoveSpacesFromName(nom);
1326// Si le nom ne commence pas par un slash, c'est le repertoire courant
1327if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
1328else {
1329 string xx = nom.substr(1);
1330 size_t p = xx.find('/');
1331 if (p < xx.length()) {
1332 nomrep = xx.substr(0,p);
1333 nomobj = xx.substr(p+1);
1334 }
1335 else {
1336 nomrep = xx;
1337 nomobj = "";
1338 }
1339 }
1340int rc = 0;
1341NObjDirList::iterator it = myDirs->find(nomrep);
1342if (it != myDirs->end()) rc = (*it).second.id;
1343return(rc);
1344}
1345
Note: See TracBrowser for help on using the repository browser.