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

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

GetTmpDir SetTmpDir ds nobjmgr.h
re-ecriture commande sur piconsole en bleu/bleu_gras
suppression OBJ ds CrMakeFile

rz+cmv 31/10/00

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