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