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