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