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