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