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

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

finalisation interfacage TMatrix, PixelMap - Reza 17/11/99

File size: 34.7 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);
370}
371
372
373
374//++
375// Titre Gestion de la liste des objets
376//--
377//++
378// void AddObj(AnyDataObj* obj, string& nom)
379// Ajoute l'objet "obj" à la liste, identifié par "nom".
380// Si un objet de même nom existe, l'ancien objet est renommé en concaténant
381// un numéro à son nom.
382// void DelObj(string const& nom, bool fgd=true)
383// Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
384// void DelObjects(string const& patt, bool fgd=true)
385// Supprime l'ensemble des objets dont le nom correspond au patron "patt".
386// Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
387// AnyDataObj* GetObj(string const& nom)
388// Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
389// pas dans la liste.
390// void RenameObj(string const& nom, string& nomnew)
391// Change le nom d'un objet dans la liste.
392// void CopyObj(string const& nom, string& nomcp)
393// Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
394//--
395
396
397/* --Methode-- */
398bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
399{
400
401if (obj == NULL) return(false);
402// On verifie si l'objet est deja dans la liste
403NObjList::iterator it;
404for(it = myObjs->begin(); it != myObjs->end(); it++) {
405 if ((*it).second.obj == obj) {
406 cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
407 return(false);
408 }
409 }
410string nobj;
411string nrep;
412char buff[32];
413int did = ParseObjectName(nom, nrep, nobj);
414if (did == 0) {
415 if (!crd) {
416 cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
417 return(false);
418 }
419 else { CreateDir(nrep); did = myDirId; }
420 }
421
422// Si c'est le repertoire /autoc, on nettoie
423if (nrep == "autoc") {
424 CleanDir(nrep);
425 }
426
427myNObj++;
428if (nobj.length() < 1) {
429 sprintf(buff,"O%d", myNObj);
430 nobj = buff;
431 }
432
433nom = '/' + nrep + '/' + nobj;
434NObjDirList::iterator itr = myDirs->find(nrep);
435if ((*itr).second.lock) {
436 cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
437 return(false);
438 }
439it = myObjs->find(nom);
440if (it != myObjs->end()) { // l'objet existe deja
441 if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean
442 sprintf(buff, "%d", (*it).second.oid);
443 string nomnew = "/autoc/" + nobj + buff;
444 RenameObj(nom, nomnew);
445 }
446 else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
447 string on,od;
448// ParseObjectName((*it).first, od, on);
449 sprintf(buff, "%d", (*it).second.oid);
450 string nomnew = "/old/" + nobj + buff;
451 RenameObj(nom, nomnew);
452 }
453 else { // Sinon, on remplace l'objet
454 cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
455 DelObj(nom);
456 }
457 }
458
459nobj_item no;
460no.obj = obj;
461no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
462no.oid = myNObj;
463no.dirid = did;
464(*myObjs)[nom] = no;
465
466(*itr).second.nobj++;
467
468if (verbeux) cout << "NamedObjMgr::AddObj() Object " << nom << " ( "
469 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
470return(true);
471}
472
473/* --Methode-- */
474bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
475{
476string n1,r1,n2,r2;
477int dids = ParseObjectName(nom, r1, n1);
478NObjDirList::iterator itr1 = myDirs->find(r1);
479int did = ParseObjectName(nomnew, r2, n2);
480NObjDirList::iterator itr2 = myDirs->find(r2);
481
482if (did == 0) {
483 cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
484 return(false);
485 }
486nom = '/' + r1 + '/' + n1;
487nomnew = '/' + r2 + '/' + n2;
488NObjList::iterator it1 = myObjs->find(nom);
489if (it1 == myObjs->end()) {
490 cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl;
491 return(false);
492 }
493NObjList::iterator it2 = myObjs->find(nomnew);
494if (it2 != myObjs->end()) {
495 cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl;
496 return(false);
497 }
498
499if ( (*itr1).second.lock || (*itr2).second.lock ) {
500 cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !"
501 << endl;
502 return(false);
503 }
504
505
506nobj_item no = (*it1).second;
507no.dirid = did;
508myObjs->erase(it1);
509NObjDirList::iterator itr = myDirs->find(r1);
510(*itr).second.nobj--;
511(*myObjs)[nomnew] = no;
512itr = myDirs->find(r2);
513(*itr).second.nobj++;
514if (verbeux)
515 cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
516return(true);
517}
518
519/* --Methode-- */
520bool NamedObjMgr::CopyObj(string & nom, string& nomcp)
521{
522if(nomcp.length()<=0)
523 {cout<<"NamedObjMgr::CopyObj() Error, copied obj name "<<nomcp<<" not valid"<<endl;
524 return(false);}
525NObjMgrAdapter* obnom = GetObjAdapter(nom);
526if(obnom==NULL)
527 {cout<<"NamedObjMgr::CopyObj() Error - No "<<nom<<" object !"<<endl;
528 return(false);}
529AnyDataObj* obnomcp = obnom->GetCopyObj();
530if(obnomcp==NULL) return(false);
531if(! AddObj(obnomcp,nomcp) ) {delete obnomcp; return(false);}
532return true;
533}
534
535/* --Methode-- */
536bool NamedObjMgr::DelObj(string & nom, bool fgd)
537{
538string n1,r1;
539ParseObjectName(nom, r1, n1);
540nom = '/' + r1 + '/' + n1;
541NObjList::iterator it = myObjs->find(nom);
542if (it == myObjs->end()) return(false);
543NObjDirList::iterator itr = myDirs->find(r1);
544if ( (*itr).second.lock ) {
545 cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
546 return(false);
547 }
548list<int>::iterator ii;
549if (myImgApp) {
550//DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
551 for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
552 myImgApp->DelWRsId((*ii));
553}
554delete (*it).second.obja; // destruction de l'adaptateur
555if (fgd) delete (*it).second.obj;
556
557myObjs->erase(it);
558(*itr).second.nobj--;
559
560if (!verbeux) return(true);
561if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
562else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
563return(true);
564}
565
566/* --Methode-- */
567bool NamedObjMgr::DelObj_Id(int oid)
568{
569NObjList::iterator it;
570string nom;
571bool of = false;
572for(it = myObjs->begin(); it != myObjs->end(); it++)
573 if ( (*it).second.oid == oid ) {
574 of = true; nom = (*it).first;
575 break;
576 }
577if (of) return(DelObj(nom, true));
578else return(false);
579}
580
581/* --Methode-- */
582void NamedObjMgr::DelObjects(string & patt, bool fgd)
583{
584string n1,r1;
585ParseObjectName(patt, r1, n1);
586patt = '/' + r1 + '/' + n1;
587NObjList::iterator it;
588list<string> odel;
589string cn;
590for(it = myObjs->begin(); it != myObjs->end(); it++) {
591 cn = (*it).first;
592 if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
593 }
594list<string>::iterator ii;
595for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii, fgd);
596}
597
598/* --Methode-- */
599AnyDataObj* NamedObjMgr::GetObj(string & nom)
600{
601string n1,r1;
602ParseObjectName(nom, r1, n1);
603nom = '/' + r1 + '/' + n1;
604NObjList::iterator it = myObjs->find(nom);
605if (it == myObjs->end()) return(NULL);
606return((*it).second.obj);
607}
608
609/* --Methode-- */
610NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
611{
612string n1,r1;
613ParseObjectName(nom, r1, n1);
614nom = '/' + r1 + '/' + n1;
615NObjList::iterator it = myObjs->find(nom);
616if (it == myObjs->end()) return(NULL);
617return((*it).second.obja);
618}
619
620/* --Methode-- */
621void NamedObjMgr::ListObjs(string & patt)
622{
623int k;
624AnyDataObj* obj=NULL;
625string ctyp;
626char strg[256];
627
628string n1,r1;
629ParseObjectName(patt, r1, n1);
630patt = '/' + r1 + '/' + n1;
631 cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
632NObjList::iterator it; k = 0;
633string cn;
634for(it = myObjs->begin(); it != myObjs->end(); it++) {
635 cn = (*it).first;
636 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
637 obj = (*it).second.obj;
638 ctyp = typeid(*obj).name();
639 sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
640 ctyp = strg;
641 cout << ctyp << "\n" ;
642 k++;
643}
644cout << endl;
645return;
646}
647
648/* --Methode-- */
649void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
650{
651string n1,r1;
652if (patt.length() < 1) return;
653bool fgr = (patt[0] == '/') ? true : false;
654ParseObjectName(patt, r1, n1);
655patt = '/' + r1 + '/' + n1;
656NObjList::iterator it;
657string cn;
658for(it = myObjs->begin(); it != myObjs->end(); it++) {
659 cn = (*it).first;
660 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
661 if (fgr) lst.push_back(cn);
662 else {
663 ParseObjectName(cn, r1, n1);
664 lst.push_back(n1);
665 }
666 }
667}
668
669//++
670// Titre Entrées-Sorties (I/O) sur les objets
671//--
672//++
673// void ReadObj(PInPersist& s, int num=-1)
674// Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
675// et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
676// sur le flot "s" sont créés et ajoutés à la liste.
677// void ReadObj(string const & nomppf, string nobj="")
678// Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
679// à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
680// composé à partir du nom de fichier.
681//--
682
683/* --Methode-- */
684void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
685{
686PPersist* ppobj=NULL;
687bool ok = true;
688#ifdef SANS_EVOLPLANCK
689TRY{
690 PInPersist pis(flnm);
691 ppobj = PPersistMgr::ReadObject(pis);
692 if (ppobj == NULL) ok = false;
693} CATCH(merr)
694 { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
695 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
696#else
697try {
698 PInPersist pis(flnm);
699 ppobj = pis.ReadObject();
700 }
701catch (IOExc iox) {
702 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
703 ok = false;
704 }
705#endif
706if (!ok) return;
707if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
708AddObj(ppobj->DataObj(), nobj, true);
709return;
710}
711
712/* --Methode-- */
713void NamedObjMgr::ReadObj(PInPersist& s, int num)
714{
715int_4 i, cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
716int n0, n1;
717bool ok = true;
718PPersist* obj=NULL;
719string nom;
720
721int nread = 0;
722if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
723 if (num >= 0) {
724 cerr << "NamedObjMgr::ReadObj(PInPersist, " << num << " Error! NbTags ="
725 << s.NbTags() << endl;
726 return;
727 }
728
729#ifdef SANS_EVOLPLANCK
730 TRY {
731 obj = PPersistMgr::ReadObject(s);
732 if (obj == NULL) ok = false;
733 } CATCH(merr) {
734 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
735 ok = false;
736 } ENDTRY;
737#else
738try {
739 obj = s.ReadObject();
740 }
741catch (IOExc iox) {
742 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
743 ok = false;
744 }
745#endif
746
747 if (!ok) return;
748 nom = "";
749 AddObj(obj->DataObj(), nom);
750 nread++;
751}
752
753if (num < 0) { n0 = 0; n1 = s.NbTags(); }
754else { n0 = num; n1 = num+1; }
755for(i=n0; i<n1; i++) {
756#ifdef SANS_EVOLPLANCK
757 key = s.TagKey(i, cid, ln);
758 if (ln <= 0) nom = "";
759 else nom = s.TagName(i);
760 s.GotoTag(i);
761 TRY {
762 obj = PPersistMgr::ReadObject(s);
763 if (obj == NULL) ok = false;
764 } CATCH(merr) {
765 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
766 ok = false;
767 } ENDTRY;
768#else
769 s.GotoTagNum(i);
770 nom = s.GetTagName(i);
771 try {
772 obj = s.ReadObject();
773 }
774 catch (IOExc iox) {
775 cerr << "NamedObjMgr::ReadObj()/Error Exception - Msg= " << iox.Msg() << endl;
776 ok = false;
777 }
778#endif
779 if (ok) { AddObj(obj->DataObj(), nom, true); nread++; }
780}
781
782cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
783return;
784}
785/* --Methode-- */
786void NamedObjMgr::ReadAll(string const & flnm)
787{
788bool ok = true;
789PPersist* obj=NULL;
790
791PInPersist* ppin;
792#ifdef SANS_EVOLPLANCK
793TRY{
794 ppin = new PInPersist(flnm);
795 if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
796 else obj = NULL;
797} CATCH(merr)
798 { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
799 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
800#else
801try {
802 ppin = new PInPersist(flnm);
803 if (ppin->NbTags() < 1) obj = ppin->ReadObject();
804 else obj = NULL;
805}
806catch (IOExc iox) {
807 cerr << "NamedObjMgr::ReadAll()/Error Exception - Msg= " << iox.Msg() << endl;
808 ok = false;
809}
810#endif
811if (!ok) return;
812if (obj) {
813 string nom = servnobjm->FileName2Name(flnm);
814 AddObj(obj->DataObj(), nom);
815 }
816else ReadObj((*ppin), -1);
817delete ppin;
818return;
819}
820
821/* --Methode-- */
822void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
823{
824bool ok = true;
825#ifdef SANS_EVOLPLANCK
826RzImage* obj;
827#else
828//CMV_A_FAIRE RzImage* obj;
829#endif
830
831// obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
832#ifdef SANS_EVOLPLANCK
833TRY{
834 obj = RzReadFits((char*)flnm.c_str());
835 if (obj == NULL) ok = false;
836} CATCH(merr) {
837 printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
838 ok = false;
839} ENDTRY;
840if (ok) {
841 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
842 AddObj((AnyDataObj*)obj, nobj);
843}
844#else
845 printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n");
846#endif
847return;
848}
849
850
851static int key_for_write = 5000;
852/* --Methode-- */
853void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
854{
855if (nom.length() < 1) return;
856string nob,rep;
857ParseObjectName(nom, rep, nob);
858nom = '/' + rep + '/' + nob;
859NObjMgrAdapter* obja=NULL;
860string nomf = (keeppath) ? nom : nob;
861obja = GetObjAdapter(nom);
862if (obja == NULL) return;
863printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
864 nom.c_str(), typeid(*(obja->GetDataObj())).name());
865obja->SavePPF(s, nomf);
866return;
867}
868
869/* --Methode-- */
870void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
871{
872string n1,r1;
873if (patt.length() < 1) return;
874bool keeppath = (patt[0] == '/') ? true : false;
875ParseObjectName(patt, r1, n1);
876patt = '/' + r1 + '/' + n1;
877
878bool ok = true;
879POutPersist* pout;
880#ifdef SANS_EVOLPLANCK
881TRY{
882 pout = new POutPersist(flnm);
883} CATCH(merr)
884 { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n",
885 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
886#else
887try {
888 pout = new POutPersist(flnm);
889}
890catch (IOExc iox) {
891 cerr << "NamedObjMgr::SaveObjects()/Error Exception - Msg= " << iox.Msg() << endl;
892 ok = false;
893}
894#endif
895if (!ok) return;
896NObjList::iterator it;
897string cn;
898for(it = myObjs->begin(); it != myObjs->end(); it++) {
899 cn = (*it).first;
900 if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
901 SaveObj(cn, (*pout), keeppath);
902 }
903delete pout;
904return;
905}
906
907/* --Methode-- */
908void NamedObjMgr::SaveAll(string const& flnm)
909{
910bool ok = true;
911
912POutPersist* pout;
913#ifdef SANS_EVOLPLANCK
914TRY{
915 pout = new POutPersist(flnm);
916} CATCH(merr)
917 { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
918 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
919#else
920try {
921 pout = new POutPersist(flnm);
922}
923catch (IOExc iox) {
924 cerr << "NamedObjMgr::SaveAll()/Error Exception - Msg= " << iox.Msg() << endl;
925 ok = false;
926}
927#endif
928if (!ok) return;
929NObjList::iterator it;
930string no;
931for(it = myObjs->begin(); it != myObjs->end(); it++) {
932 no = (*it).first;
933 SaveObj(no, (*pout), true);
934 }
935delete pout;
936return;
937}
938
939/* --Methode-- */
940void NamedObjMgr::SaveFits(string& nom, string const & flnm)
941{
942NObjMgrAdapter* obja=NULL;
943obja = GetObjAdapter(nom);
944if (obja == NULL) return;
945obja->SaveFits(flnm);
946return;
947}
948
949
950
951/* --Methode-- */
952void NamedObjMgr::PrintObj(string& nom)
953{
954NObjMgrAdapter* obja=NULL;
955obja = GetObjAdapter(nom);
956if (obja == NULL) return;
957AnyDataObj* ob = obja->GetDataObj();
958if (ob == NULL) {
959 cerr << "NamedObjMgr::PrintObj() / Error - NULL object ! in " << nom << endl;
960 return;
961 }
962string ctyp = typeid(*ob).name();
963cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
964obja->Print(cout);
965
966return;
967}
968
969/* --Methode-- */
970void NamedObjMgr::DisplayObj(string& nom, string dopt)
971{
972NObjMgrAdapter* obja=NULL;
973obja = GetObjAdapter(nom);
974if (obja == NULL) {
975 cout << "NamedObjMgr::DisplayObj() Error , No object with name " << nom << endl;
976 return;
977}
978if (obja->GetDataObj() == NULL) {
979 cerr << "NamedObjMgr::DisplayObj() / Error - NULL object ! in " << nom << endl;
980 return;
981 }
982if (!myImgApp) return;
983
984PIDrawer * dr = NULL;
985P2DArrayAdapter* arr = NULL;
986dr = obja->GetDrawer(dopt);
987if (!dr) arr = obja->Get2DArray(dopt);
988
989if (!dr && !arr) {
990 string ctyp = typeid(*(obja->GetDataObj())).name();
991 cout << "NamedObjMgr::DisplayObj() Error , No display for " << ctyp << endl;
992 return;
993 }
994
995int wrsid = 0;
996bool fgsr = true;
997int opt = servnobjm->DecodeDispOption(dopt, fgsr);
998
999string n1,r1;
1000ParseObjectName(nom, r1, n1);
1001
1002if (dr) {
1003 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
1004 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
1005 else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
1006 }
1007else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
1008
1009if(wrsid != 0) {
1010 NObjList::iterator it = myObjs->find(nom);
1011 if (it == myObjs->end()) return;
1012 (*it).second.wrsid.push_back(wrsid);
1013 }
1014if (fgsr) myImgApp->RestoreGraphicAtt();
1015return;
1016}
1017
1018/* --Methode-- */
1019void NamedObjMgr::DisplayImage(string& nom, string dopt)
1020{
1021NObjMgrAdapter* obja=NULL;
1022obja = GetObjAdapter(nom);
1023if (obja == NULL) {
1024 cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl;
1025 return;
1026}
1027if (obja->GetDataObj() == NULL) {
1028 cerr << "NamedObjMgr::DisplayImage() / Error - NULL object ! in " << nom << endl;
1029 return;
1030 }
1031if (!myImgApp) return;
1032
1033P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1034
1035if (!arr) {
1036 string ctyp = typeid(*(obja->GetDataObj())).name();
1037 cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl;
1038 return;
1039 }
1040
1041string n1,r1;
1042ParseObjectName(nom, r1, n1);
1043
1044int wrsid = 0;
1045bool fgsr = true;
1046int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1047wrsid = myImgApp->DispImage(arr, n1, opt);
1048
1049if(wrsid != 0) {
1050 NObjList::iterator it = myObjs->find(nom);
1051 if (it == myObjs->end()) return;
1052 (*it).second.wrsid.push_back(wrsid);
1053 }
1054if (fgsr) myImgApp->RestoreGraphicAtt();
1055return;
1056}
1057/* --Methode-- */
1058void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
1059{
1060NObjMgrAdapter* obja=NULL;
1061obja = GetObjAdapter(nom);
1062if (obja == NULL) {
1063 cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl;
1064 return;
1065}
1066if (obja->GetDataObj() == NULL) {
1067 cerr << "NamedObjMgr::DisplaySurf3D() / Error - NULL object ! in " << nom << endl;
1068 return;
1069 }
1070if (!myImgApp) return;
1071
1072P2DArrayAdapter* arr = obja->Get2DArray(dopt);
1073
1074if (!arr) {
1075 string ctyp = typeid(*(obja->GetDataObj())).name();
1076 cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl;
1077 return;
1078 }
1079
1080if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
1081 cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
1082 << "x" << arr->YSize() << ") too big (max=250x250)" << endl;
1083 delete arr;
1084 return;
1085 }
1086
1087string n1,r1;
1088ParseObjectName(nom, r1, n1);
1089
1090int wrsid = 0;
1091bool fgsr = true;
1092int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1093PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
1094wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
1095if(wrsid >= 0) {
1096 NObjList::iterator it = myObjs->find(nom);
1097 if (it == myObjs->end()) return;
1098 (*it).second.wrsid.push_back(wrsid);
1099 }
1100
1101if (fgsr) myImgApp->RestoreGraphicAtt();
1102return;
1103}
1104
1105/* --Methode-- */
1106void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
1107 string& erx, string& ery, string& erz, string& wt,
1108 string& label, string dopt, bool fg3d)
1109{
1110AnyDataObj* obj=GetObj(nom);
1111if (obj == NULL) {
1112 cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl;
1113 return;
1114}
1115if (!myImgApp) return;
1116
1117NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
1118if (nt == NULL) {
1119// if (typeid(*obj) != typeid(NTupleInterface)) {
1120 string ctyp = typeid(*obj).name();
1121 cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl;
1122 return;
1123 }
1124
1125int wrsid = 0;
1126bool fgsr = true;
1127dopt = "defline," + dopt;
1128int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1129
1130string n1,r1;
1131ParseObjectName(nom, r1, n1);
1132
1133if ( fg3d && (nmz.length()>0) ) { // Display 3D
1134 PINTuple3D* pin = new PINTuple3D(nt, false);
1135 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
1136 pin->SelectWt(wt.c_str());
1137 pin->SelectLabel(label.c_str());
1138 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
1139 string titre = nmz + "%" + nmy + "%" + nmz;
1140 wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);
1141}
1142else {
1143 PINTuple* pin = new PINTuple(nt, false);
1144 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
1145 pin->SelectXY(nmx.c_str(), nmy.c_str());
1146 pin->SelectWt(wt.c_str());
1147 pin->SelectLabel(label.c_str());
1148 pin->SelectErrBar(erx.c_str(), ery.c_str());
1149 string titre = nmy + "%" + nmx;
1150 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
1151 }
1152
1153if(wrsid >= 0) {
1154 NObjList::iterator it = myObjs->find(nom);
1155 if (it == myObjs->end()) return;
1156 (*it).second.wrsid.push_back(wrsid);
1157 }
1158
1159if (fgsr) myImgApp->RestoreGraphicAtt();
1160return;
1161}
1162
1163/* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
1164void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
1165// Pour le display 2D ou 3D d'un ``GeneralFitData''.
1166//| nom = nom de l'objet GeneralFitData a representer.
1167//| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
1168//| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
1169//| Pour le display 2D, numvary="" string vide.
1170//| err = qu'elles erreurs faut il representer ?
1171//| - 2D : x y xy (display y=f(x))
1172//| - 3D : x y z xy xz yz xzy (display z=f(x,y))
1173//| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
1174//| les barres d'erreurs sont representees.
1175//| opt = options generales pour le display.
1176{
1177AnyDataObj* obj=GetObj(nom);
1178if(obj == NULL)
1179 {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl;
1180 return;}
1181if(!myImgApp) return;
1182if(typeid(*obj) != typeid(GeneralFitData))
1183 {string ctyp = typeid(*obj).name();
1184 cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl;
1185 return;}
1186
1187// Decodage des options classiques
1188bool fgsr = true;
1189int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1190// Decodage des erreurs a representer
1191bool errx=false, erry=false, errz=false;
1192if(err.length()>0) {
1193 for(int i=0;i<err.length();i++)
1194 if (err[i]=='x' || err[i]=='X') errx = true;
1195 else if(err[i]=='y' || err[i]=='Y') erry = true;
1196 else if(err[i]=='z' || err[i]=='Z') errz = true;
1197}
1198// Decodage des numeros de variables en abscisse
1199 int numvx=-1, numvy=-1;
1200 if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
1201 if(numvary.length()>0) numvy = atoi(numvary.c_str());
1202
1203 string n1,r1;
1204 ParseObjectName(nom, r1, n1);
1205
1206 int wrsid = 0;
1207 if(numvy>=0) { // display 3D
1208 PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
1209 pigfd->SelectXY(numvx,numvy);
1210 pigfd->SelectErrBar(errx,erry,errz);
1211 wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);
1212} else { // display 2D
1213 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
1214 pigfd->SelectX(numvx);
1215 pigfd->SelectErrBar(errx,erry);
1216 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
1217}
1218
1219if(wrsid >= 0) {
1220 NObjList::iterator it = myObjs->find(nom);
1221 if (it == myObjs->end()) return;
1222 (*it).second.wrsid.push_back(wrsid);
1223}
1224if (fgsr) myImgApp->RestoreGraphicAtt();
1225return;
1226}
1227
1228/* --Methode--
1229void NamedObjMgr::DisplayImage(string& nom, string dopt)
1230{
1231 cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
1232}
1233*/
1234
1235
1236
1237
1238/* --Methode-- */
1239void NamedObjMgr::SetGraphicAttributes(string gratt)
1240{
1241bool fg = false;
1242servnobjm->DecodeDispOption(gratt, fg);
1243Services2NObjMgr::SetDefaultStatsOption(Services2NObjMgr::GetStatsOption(gratt));
1244}
1245
1246/* --Methode-- */
1247void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
1248{
1249if (!myImgApp) return;
1250if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
1251else myImgApp->SetZone(nzx, nzy);
1252}
1253
1254/* --Methode-- */
1255void NamedObjMgr::AddWRsId(string & nom, int wrsid)
1256{
1257if(wrsid != 0) {
1258 NObjList::iterator it = myObjs->find(nom);
1259 if (it == myObjs->end()) return;
1260 (*it).second.wrsid.push_back(wrsid);
1261 }
1262return;
1263}
1264
1265/* --Methode-- */
1266void NamedObjMgr::UpdateObjMgrWindow(int did)
1267{
1268if (!myImgApp) return;
1269(myImgApp->ObjMgrW())->ClearHelpList();
1270
1271NObjList::iterator it;
1272string cn;
1273for(it = myObjs->begin(); it != myObjs->end(); it++) {
1274 if ((*it).second.dirid != did) continue;
1275 cn = (*it).first.substr(1);
1276 cn = cn.substr(cn.find('/')+1) + " (T= " + typeid(*((*it).second.obj)).name() + ")" ;
1277 (myImgApp->ObjMgrW())->AddObj(cn.c_str());
1278 }
1279}
1280
1281
1282/* Nouvelle-Fonction */
1283void RemoveSpacesFromName(string & nom)
1284{
1285// on supprime les blancs de debut et de fin
1286size_t p = nom.find_first_not_of(" ");
1287if(p>nom.length()) { nom = ""; return; }
1288nom = nom.substr(p);
1289p = nom.find(' ');
1290if(p>nom.length()) p=nom.length();
1291nom = nom.substr(0, p);
1292}
1293
1294/* Nouvelle-Fonction */
1295bool CheckDirName(string & nom)
1296{
1297RemoveSpacesFromName(nom);
1298if (nom.length() < 1) return(false);
1299if (nom[0] == '/') nom = nom.substr(1) ;
1300size_t p = nom.find('/');
1301if (p < nom.length()) nom = nom.substr(0,p);
1302if (nom.length() < 1) return(false);
1303return(true);
1304}
1305
1306/* Nouvelle-Fonction */
1307int ParseObjectName(string & nom, string & nomrep, string & nomobj)
1308{
1309RemoveSpacesFromName(nom);
1310// Si le nom ne commence pas par un slash, c'est le repertoire courant
1311if (nom[0] != '/') { nomrep = *currDir; nomobj = nom; }
1312else {
1313 string xx = nom.substr(1);
1314 size_t p = xx.find('/');
1315 if (p < xx.length()) {
1316 nomrep = xx.substr(0,p);
1317 nomobj = xx.substr(p+1);
1318 }
1319 else {
1320 nomrep = xx;
1321 nomobj = "";
1322 }
1323 }
1324int rc = 0;
1325NObjDirList::iterator it = myDirs->find(nomrep);
1326if (it != myDirs->end()) rc = (*it).second.id;
1327return(rc);
1328}
1329
Note: See TracBrowser for help on using the repository browser.