| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MParList //
|
|---|
| 28 | // //
|
|---|
| 29 | // This class contains a list of different parameter containers. //
|
|---|
| 30 | // //
|
|---|
| 31 | // A parameter container is an object which is derived from //
|
|---|
| 32 | // MParContainer. //
|
|---|
| 33 | // //
|
|---|
| 34 | // Normally a parameter container is used for data exchange between two //
|
|---|
| 35 | // tasks at runtime. //
|
|---|
| 36 | // //
|
|---|
| 37 | // You can add every parameter container (Named object) to the //
|
|---|
| 38 | // instance and access it from somewhere else via its Name. //
|
|---|
| 39 | // //
|
|---|
| 40 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 41 | #include "MParList.h"
|
|---|
| 42 |
|
|---|
| 43 | #include <fstream> // ofstream, SavePrimitive
|
|---|
| 44 |
|
|---|
| 45 | #include <TNamed.h>
|
|---|
| 46 | #include <TClass.h>
|
|---|
| 47 | #include <TOrdCollection.h>
|
|---|
| 48 |
|
|---|
| 49 | #include "MLog.h"
|
|---|
| 50 | #include "MLogManip.h"
|
|---|
| 51 |
|
|---|
| 52 | #include "MIter.h"
|
|---|
| 53 | #include "MTaskList.h"
|
|---|
| 54 |
|
|---|
| 55 | ClassImp(MParList);
|
|---|
| 56 |
|
|---|
| 57 | using namespace std;
|
|---|
| 58 |
|
|---|
| 59 | static const TString gsDefName = "MParList";
|
|---|
| 60 | static const TString gsDefTitle = "A list of Parameter Containers";
|
|---|
| 61 |
|
|---|
| 62 | // --------------------------------------------------------------------------
|
|---|
| 63 | //
|
|---|
| 64 | // creates an empty list
|
|---|
| 65 | //
|
|---|
| 66 | void MParList::Init(const char *name, const char *title)
|
|---|
| 67 | {
|
|---|
| 68 | fName = name ? name : gsDefName.Data();
|
|---|
| 69 | fTitle = title ? title : gsDefTitle.Data();
|
|---|
| 70 |
|
|---|
| 71 | //
|
|---|
| 72 | // This sets a flag that the list is the owner, which means
|
|---|
| 73 | // that the destructor of the list deletes all it's objects
|
|---|
| 74 | //
|
|---|
| 75 | fContainer = new TOrdCollection;
|
|---|
| 76 | fAutodelete = new TOrdCollection;
|
|---|
| 77 |
|
|---|
| 78 | gROOT->GetListOfCleanups()->Add(fContainer);
|
|---|
| 79 | gROOT->GetListOfCleanups()->Add(fAutodelete);
|
|---|
| 80 | fContainer->SetBit(kMustCleanup);
|
|---|
| 81 | fAutodelete->SetBit(kMustCleanup);
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | // --------------------------------------------------------------------------
|
|---|
| 86 | //
|
|---|
| 87 | // default constructor
|
|---|
| 88 | // creates an empty list
|
|---|
| 89 | //
|
|---|
| 90 | MParList::MParList(const char *name, const char *title)
|
|---|
| 91 | {
|
|---|
| 92 | Init(name, title);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // --------------------------------------------------------------------------
|
|---|
| 96 | //
|
|---|
| 97 | // Copy constructor. It copies all entries of the parameter list, but it
|
|---|
| 98 | // takes care of, that the automatically created entries are only deleted
|
|---|
| 99 | // once. (doesn't copy the list which holds the automatically created
|
|---|
| 100 | // entries)
|
|---|
| 101 | //
|
|---|
| 102 | MParList::MParList(const MParList &ts, const char *name, const char *title) : MParContainer()
|
|---|
| 103 | {
|
|---|
| 104 | Init(name, title);
|
|---|
| 105 |
|
|---|
| 106 | fContainer->AddAll(ts.fContainer);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | // --------------------------------------------------------------------------
|
|---|
| 110 | //
|
|---|
| 111 | // If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
|
|---|
| 112 | // by the destructor
|
|---|
| 113 | //
|
|---|
| 114 | MParList::~MParList()
|
|---|
| 115 | {
|
|---|
| 116 | //
|
|---|
| 117 | // Case:
|
|---|
| 118 | // 1) MParList is owner of the containers:
|
|---|
| 119 | // All container are stored in fContainer, and become deleted by
|
|---|
| 120 | // 'delete fContainer'. Some of these containers, which were
|
|---|
| 121 | // created automatically are stored in fAutodelete, too. To prevent
|
|---|
| 122 | // double deletion this containers are not deleted by the destructor
|
|---|
| 123 | // of fAutodelete.
|
|---|
| 124 | // 2) MParList is not owner of the containers:
|
|---|
| 125 | // The containers which were Added by AddToList are not touched.
|
|---|
| 126 | // Only the containers which were created automatically are also
|
|---|
| 127 | // automatically deleted.
|
|---|
| 128 | //
|
|---|
| 129 | IsOwner() ? fContainer->SetOwner() : fAutodelete->SetOwner();
|
|---|
| 130 |
|
|---|
| 131 | TIter Next(fContainer);
|
|---|
| 132 | TObject *o=0;
|
|---|
| 133 | while ((o=Next()))
|
|---|
| 134 | if (o->TestBit(kCanDelete))
|
|---|
| 135 | delete fContainer->Remove(o);
|
|---|
| 136 |
|
|---|
| 137 | // FIXME? If fContainer is owner do we have to remove the object
|
|---|
| 138 | // from fAutodelete due to the access when checking for a
|
|---|
| 139 | // garbage collection?
|
|---|
| 140 | delete fContainer;
|
|---|
| 141 | delete fAutodelete;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | // --------------------------------------------------------------------------
|
|---|
| 145 | //
|
|---|
| 146 | // If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
|
|---|
| 147 | // by the destructor
|
|---|
| 148 | //
|
|---|
| 149 | void MParList::SetOwner(Bool_t enable)
|
|---|
| 150 | {
|
|---|
| 151 | enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | // --------------------------------------------------------------------------
|
|---|
| 155 | //
|
|---|
| 156 | // Set the logging streamer of the parameter list and all contained
|
|---|
| 157 | // parameter containers
|
|---|
| 158 | //
|
|---|
| 159 | void MParList::SetLogStream(MLog *log)
|
|---|
| 160 | {
|
|---|
| 161 | fContainer->R__FOR_EACH(MParContainer, SetLogStream)(log);
|
|---|
| 162 | MParContainer::SetLogStream(log);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | void MParList::SetDisplay(MStatusDisplay *d)
|
|---|
| 166 | {
|
|---|
| 167 | fContainer->R__FOR_EACH(MParContainer, SetDisplay)(d);
|
|---|
| 168 | MParContainer::SetDisplay(d);
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | // --------------------------------------------------------------------------
|
|---|
| 172 | //
|
|---|
| 173 | // Add a single container to the list.
|
|---|
| 174 | //
|
|---|
| 175 | // If 'where' is given, the object will be added after this.
|
|---|
| 176 | //
|
|---|
| 177 | Bool_t MParList::AddToList(MParContainer *cont, MParContainer *where)
|
|---|
| 178 | {
|
|---|
| 179 | //
|
|---|
| 180 | // check if the object (you want to add) exists
|
|---|
| 181 | //
|
|---|
| 182 | if (!cont)
|
|---|
| 183 | return kFALSE;
|
|---|
| 184 |
|
|---|
| 185 | //
|
|---|
| 186 | // Get Name of new container
|
|---|
| 187 | //
|
|---|
| 188 | const char *name = cont->GetName();
|
|---|
| 189 |
|
|---|
| 190 | //
|
|---|
| 191 | // Check if the new container is already existing in the list
|
|---|
| 192 | //
|
|---|
| 193 | const TObject *objn = fContainer->FindObject(name);
|
|---|
| 194 | const TObject *objt = fContainer->FindObject(cont);
|
|---|
| 195 |
|
|---|
| 196 | if (objn || objt)
|
|---|
| 197 | {
|
|---|
| 198 | //
|
|---|
| 199 | // If the container is already in the list ignore it.
|
|---|
| 200 | //
|
|---|
| 201 | if (objt || objn==cont)
|
|---|
| 202 | {
|
|---|
| 203 | *fLog << warn << dbginf << "Warning: Container '" << cont->GetName() << ", 0x" << (void*)cont;
|
|---|
| 204 | *fLog << "' already existing in '" << GetName() << "'... ignoring." << endl;
|
|---|
| 205 | return kTRUE;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | //
|
|---|
| 209 | // Otherwise add it to the list, but print a warning message
|
|---|
| 210 | //
|
|---|
| 211 | *fLog << warn << dbginf << "Warning: Container with the same name '" << cont->GetName();
|
|---|
| 212 | *fLog << "' already existing in '" << GetName() << "'." << endl;
|
|---|
| 213 | *fLog << "You may not be able to get a pointer to container task by name." << endl;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | //
|
|---|
| 217 | // check if you want to add the new parameter container somewhere
|
|---|
| 218 | // special (in that case you specify "where")
|
|---|
| 219 | //
|
|---|
| 220 | if (where)
|
|---|
| 221 | {
|
|---|
| 222 | if (!fContainer->FindObject(where))
|
|---|
| 223 | {
|
|---|
| 224 | *fLog << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl;
|
|---|
| 225 | return kFALSE;
|
|---|
| 226 | }
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | if (!cont->InheritsFrom(MParContainer::Class()))
|
|---|
| 230 | {
|
|---|
| 231 | *fLog << dbginf << "Error: Cantainer MUST derive from MParContainer!" << endl;
|
|---|
| 232 | return kFALSE;
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | *fLog << inf3 << "Adding " << name << " to " << GetName() << "... " << flush;
|
|---|
| 236 |
|
|---|
| 237 | cont->SetBit(kMustCleanup);
|
|---|
| 238 | fContainer->Add(cont);
|
|---|
| 239 | *fLog << "done." << endl;
|
|---|
| 240 |
|
|---|
| 241 | return kTRUE;
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | // --------------------------------------------------------------------------
|
|---|
| 245 | //
|
|---|
| 246 | // Add all entries of the TObjArray to the list.
|
|---|
| 247 | //
|
|---|
| 248 | void MParList::AddToList(TObjArray *list)
|
|---|
| 249 | {
|
|---|
| 250 | //
|
|---|
| 251 | // check if the object (you want to add) exists
|
|---|
| 252 | //
|
|---|
| 253 | if (!list)
|
|---|
| 254 | return;
|
|---|
| 255 |
|
|---|
| 256 | MIter Next(list);
|
|---|
| 257 |
|
|---|
| 258 | MParContainer *cont = NULL;
|
|---|
| 259 | while ((cont=Next()))
|
|---|
| 260 | {
|
|---|
| 261 | cont->SetBit(kMustCleanup);
|
|---|
| 262 | AddToList(cont);
|
|---|
| 263 | }
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | // --------------------------------------------------------------------------
|
|---|
| 267 | //
|
|---|
| 268 | // Find an object with the same name in the list and replace it with
|
|---|
| 269 | // the new one. If the kIsOwner flag is set and the object was not
|
|---|
| 270 | // created automatically, the object is deleted.
|
|---|
| 271 | //
|
|---|
| 272 | Bool_t MParList::Replace(MParContainer *cont)
|
|---|
| 273 | {
|
|---|
| 274 | //
|
|---|
| 275 | // check if the object (you want to add) exists
|
|---|
| 276 | //
|
|---|
| 277 | if (!cont)
|
|---|
| 278 | return kFALSE;
|
|---|
| 279 |
|
|---|
| 280 | TObject *obj = FindObject(cont->GetName());
|
|---|
| 281 | if (!obj)
|
|---|
| 282 | {
|
|---|
| 283 | *fLog << warn << "No object with the same name '";
|
|---|
| 284 | *fLog << cont->GetName() << "' in list... adding." << endl;
|
|---|
| 285 | return AddToList(cont);
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | fContainer->Remove(obj);
|
|---|
| 289 |
|
|---|
| 290 | if (IsOwner() && !fAutodelete->FindObject(obj))
|
|---|
| 291 | delete obj;
|
|---|
| 292 |
|
|---|
| 293 | *fLog << inf2 << "MParContainer '" << cont->GetName() << "' found and replaced..." << endl;
|
|---|
| 294 |
|
|---|
| 295 | return AddToList(cont);
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | // --------------------------------------------------------------------------
|
|---|
| 299 | //
|
|---|
| 300 | // Find an object with the same name in the list and remove it.
|
|---|
| 301 | // If the kIsOwner flag is set and the object was not created
|
|---|
| 302 | // automatically, the object is deleted.
|
|---|
| 303 | //
|
|---|
| 304 | void MParList::Remove(MParContainer *cont)
|
|---|
| 305 | {
|
|---|
| 306 | //
|
|---|
| 307 | // check if the object (you want to add) exists
|
|---|
| 308 | //
|
|---|
| 309 | if (!cont)
|
|---|
| 310 | return;
|
|---|
| 311 |
|
|---|
| 312 | TObject *obj = fContainer->Remove(cont);
|
|---|
| 313 |
|
|---|
| 314 | fContainer->RecursiveRemove(obj);
|
|---|
| 315 |
|
|---|
| 316 | // if (!obj)
|
|---|
| 317 | // {
|
|---|
| 318 | // *fLog << warn << "Object not found in list..." << endl;
|
|---|
| 319 | // return;
|
|---|
| 320 | //}
|
|---|
| 321 |
|
|---|
| 322 | // *fLog << inf << "MParContainer '" << cont->GetName() << "' removed..." << endl;
|
|---|
| 323 |
|
|---|
| 324 | if (obj && IsOwner() && !fAutodelete->FindObject(obj))
|
|---|
| 325 | delete obj;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | // --------------------------------------------------------------------------
|
|---|
| 329 | //
|
|---|
| 330 | // Call MParContainer::RecursiveRemove
|
|---|
| 331 | // Call fContainer->RecursiveRemove
|
|---|
| 332 | //
|
|---|
| 333 | void MParList::RecursiveRemove(TObject *obj)
|
|---|
| 334 | {
|
|---|
| 335 | MParContainer::RecursiveRemove(obj);
|
|---|
| 336 |
|
|---|
| 337 | if (obj==fContainer)
|
|---|
| 338 | fContainer = NULL;
|
|---|
| 339 |
|
|---|
| 340 | if (fContainer)
|
|---|
| 341 | fContainer->RecursiveRemove(obj);
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | // --------------------------------------------------------------------------
|
|---|
| 345 | //
|
|---|
| 346 | // Find an object in the list.
|
|---|
| 347 | // 'name' is the name of the object you are searching for.
|
|---|
| 348 | //
|
|---|
| 349 | TObject *MParList::FindObject(const char *name) const
|
|---|
| 350 | {
|
|---|
| 351 | return fContainer->FindObject(name);
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 | // --------------------------------------------------------------------------
|
|---|
| 355 | //
|
|---|
| 356 | // check if the object is in the list or not
|
|---|
| 357 | //
|
|---|
| 358 | TObject *MParList::FindObject(const TObject *obj) const
|
|---|
| 359 | {
|
|---|
| 360 | return fContainer->FindObject(obj);
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | // --------------------------------------------------------------------------
|
|---|
| 364 | //
|
|---|
| 365 | // Find an object in the list and check for the correct inheritance.
|
|---|
| 366 | // 'name' is the name of the object you are searching for.
|
|---|
| 367 | //
|
|---|
| 368 | // In words: Find object name and check whether it inherits from classname
|
|---|
| 369 | //
|
|---|
| 370 | TObject *MParList::FindObject(const char *name, const char *classname) const
|
|---|
| 371 | {
|
|---|
| 372 | TObject *obj = fContainer->FindObject(name);
|
|---|
| 373 |
|
|---|
| 374 | if (!obj)
|
|---|
| 375 | return NULL;
|
|---|
| 376 |
|
|---|
| 377 | if (obj->InheritsFrom(classname))
|
|---|
| 378 | return obj;
|
|---|
| 379 |
|
|---|
| 380 | *fLog << dbginf << warn << "Found object '" << name << "' doesn't ";
|
|---|
| 381 | *fLog << "inherit from " << "'" << classname << "' but from '";
|
|---|
| 382 | *fLog << obj->ClassName() << "'" << endl;
|
|---|
| 383 | return NULL;
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | // --------------------------------------------------------------------------
|
|---|
| 387 | //
|
|---|
| 388 | // check if the object is in the list or not and check for the correct
|
|---|
| 389 | // inheritance
|
|---|
| 390 | //
|
|---|
| 391 | TObject *MParList::FindObject(const TObject *obj, const char *classname) const
|
|---|
| 392 | {
|
|---|
| 393 | TObject *nobj = fContainer->FindObject(obj);
|
|---|
| 394 |
|
|---|
| 395 | if (!nobj)
|
|---|
| 396 | return NULL;
|
|---|
| 397 |
|
|---|
| 398 | if (nobj->InheritsFrom(classname))
|
|---|
| 399 | return nobj;
|
|---|
| 400 |
|
|---|
| 401 | *fLog << dbginf << warn << "Found object '" << nobj->GetName() << "' ";
|
|---|
| 402 | *fLog << "doesn't inherit from " << "'" << classname << "'" << endl;
|
|---|
| 403 | return NULL;
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | // --------------------------------------------------------------------------
|
|---|
| 407 | //
|
|---|
| 408 | // Searches for the tasklist tlist (default: MTaskList) and returns
|
|---|
| 409 | // a task with the given name found in this list. If one of both isn't
|
|---|
| 410 | // found NULL is returned
|
|---|
| 411 | //
|
|---|
| 412 | MTask *MParList::FindTask(const char *name, const char *tlist) const
|
|---|
| 413 | {
|
|---|
| 414 | TObject *l = FindObject(tlist, "MTaskList");
|
|---|
| 415 | return (MTask*)(l ? l->FindObject(name) : NULL);
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | // --------------------------------------------------------------------------
|
|---|
| 419 | //
|
|---|
| 420 | // Find a tasklist which contains a task with name name
|
|---|
| 421 | //
|
|---|
| 422 | MTaskList *MParList::FindTaskListWithTask(const char *name) const
|
|---|
| 423 | {
|
|---|
| 424 | TIter Next(fContainer);
|
|---|
| 425 | TObject *o=0;
|
|---|
| 426 | while ((o=Next()))
|
|---|
| 427 | {
|
|---|
| 428 | MTaskList *l1 = dynamic_cast<MTaskList*>(o);
|
|---|
| 429 | if (!l1)
|
|---|
| 430 | continue;
|
|---|
| 431 |
|
|---|
| 432 | MTaskList *l2 = l1->FindTaskList(name);
|
|---|
| 433 | if (l2)
|
|---|
| 434 | return l2;
|
|---|
| 435 | }
|
|---|
| 436 | return 0;
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | // --------------------------------------------------------------------------
|
|---|
| 440 | //
|
|---|
| 441 | // Find a tasklist which contains a task task
|
|---|
| 442 | //
|
|---|
| 443 | MTaskList *MParList::FindTaskListWithTask(const MTask *task) const
|
|---|
| 444 | {
|
|---|
| 445 | TIter Next(fContainer);
|
|---|
| 446 | TObject *o=0;
|
|---|
| 447 | while ((o=Next()))
|
|---|
| 448 | {
|
|---|
| 449 | MTaskList *l1 = dynamic_cast<MTaskList*>(o);
|
|---|
| 450 | if (!l1)
|
|---|
| 451 | continue;
|
|---|
| 452 |
|
|---|
| 453 | MTaskList *l2 = l1->FindTaskList(task);
|
|---|
| 454 | if (l2)
|
|---|
| 455 | return l2;
|
|---|
| 456 | }
|
|---|
| 457 | return 0;
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | // --------------------------------------------------------------------------
|
|---|
| 461 | //
|
|---|
| 462 | // returns the ClassName without anything which is behind that last ';' in
|
|---|
| 463 | // string.
|
|---|
| 464 | //
|
|---|
| 465 | TString MParList::GetClassName(const char *classname)
|
|---|
| 466 | {
|
|---|
| 467 | TString cname(classname);
|
|---|
| 468 | const char *semicolon = strrchr(cname, ';');
|
|---|
| 469 |
|
|---|
| 470 | if (semicolon)
|
|---|
| 471 | cname.Remove(semicolon-cname);
|
|---|
| 472 |
|
|---|
| 473 | return cname;
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | // --------------------------------------------------------------------------
|
|---|
| 477 | //
|
|---|
| 478 | // returns the ObjectName. It is created from a class and object name.
|
|---|
| 479 | // If no object name is given the objectname is the same than the
|
|---|
| 480 | // class name. Leading dots are removed from the object name
|
|---|
| 481 | //
|
|---|
| 482 | TString MParList::GetObjectName(const char *classname, const char *objname)
|
|---|
| 483 | {
|
|---|
| 484 | TString cname(classname);
|
|---|
| 485 | const char *semicolon = strrchr(cname, ';');
|
|---|
| 486 |
|
|---|
| 487 | TString oname(objname ? objname : classname);
|
|---|
| 488 |
|
|---|
| 489 | if (semicolon)
|
|---|
| 490 | {
|
|---|
| 491 | //
|
|---|
| 492 | // Remove leading dots from objectname (eg. "MMcTrig;5.")
|
|---|
| 493 | //
|
|---|
| 494 | Int_t sz = oname.Sizeof()-2;
|
|---|
| 495 |
|
|---|
| 496 | while (sz>=0 && oname[sz]=='.')
|
|---|
| 497 | oname.Remove(sz--);
|
|---|
| 498 | }
|
|---|
| 499 | return oname;
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | // --------------------------------------------------------------------------
|
|---|
| 503 | //
|
|---|
| 504 | // Find an object in the list.
|
|---|
| 505 | // 'name' is the name of the object you are searching for.
|
|---|
| 506 | // If the object doesn't exist we try to create one from the
|
|---|
| 507 | // dictionary. If this isn't possible NULL is returned.
|
|---|
| 508 | //
|
|---|
| 509 | // An object which was created automatically is deleted automatically in
|
|---|
| 510 | // the destructor of the parameter list, too. This means, that if an
|
|---|
| 511 | // object should survive (eg. Histograms) you MUST create it by yourself
|
|---|
| 512 | // and add it to the parameter list.
|
|---|
| 513 | //
|
|---|
| 514 | // By default (you don't specify an object name) the object name is
|
|---|
| 515 | // the same as the classname
|
|---|
| 516 | //
|
|---|
| 517 | // If the classname (default classname) is of the structure
|
|---|
| 518 | // "Name;something" - containing a semicolon - evarything which is
|
|---|
| 519 | // after the last appearance of a semicolon is stripped to get the
|
|---|
| 520 | // Name of the Class. Normally this is used to number your objects.
|
|---|
| 521 | // "Name;1", "Name;2", ... If a semicolon is detected leading dots
|
|---|
| 522 | // are stripped from the object-name (eg. "name;5.")
|
|---|
| 523 | //
|
|---|
| 524 | // In words: Create object of type classname and set its name to objname.
|
|---|
| 525 | // If an object with objname already exists return it.
|
|---|
| 526 | //
|
|---|
| 527 | MParContainer *MParList::FindCreateObj(const char *classname, const char *objname)
|
|---|
| 528 | {
|
|---|
| 529 | //
|
|---|
| 530 | // If now object name (name of the object to identify it in the
|
|---|
| 531 | // List) is given use it's classname as the objectname
|
|---|
| 532 | //
|
|---|
| 533 |
|
|---|
| 534 | //
|
|---|
| 535 | // Check if the classname is a 'numbered' name (like: "MTime;2")
|
|---|
| 536 | // if so strip the number from the classname.
|
|---|
| 537 | //
|
|---|
| 538 | // Becareful: We check for the last occurance of a ';' only and we
|
|---|
| 539 | // also don't check if a number follows or something else.
|
|---|
| 540 | //
|
|---|
| 541 | // Rem: I use a TString to make the code more readyble and to get
|
|---|
| 542 | // the new object deleted automatically
|
|---|
| 543 | //
|
|---|
| 544 | TString cname = GetClassName(classname);
|
|---|
| 545 | TString oname = GetObjectName(classname, objname);
|
|---|
| 546 |
|
|---|
| 547 | //
|
|---|
| 548 | // Try to find a object with this object name which is already
|
|---|
| 549 | // in the List. If we can find one we are done.
|
|---|
| 550 | //
|
|---|
| 551 | MParContainer *pcont = (MParContainer*)FindObject(oname);
|
|---|
| 552 |
|
|---|
| 553 | if (pcont)
|
|---|
| 554 | {
|
|---|
| 555 | if (pcont->InheritsFrom(cname))
|
|---|
| 556 | return pcont;
|
|---|
| 557 |
|
|---|
| 558 | *fLog << err << "Warning: Object '" << oname << "' found in list doesn't inherit from " << cname << "." << endl;
|
|---|
| 559 | return NULL;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | //
|
|---|
| 563 | // if object is not existing in the list try to create one
|
|---|
| 564 | //
|
|---|
| 565 | *fLog << inf2 << "Object '" << oname << "' ";
|
|---|
| 566 | if (oname!=cname)
|
|---|
| 567 | *fLog << "[" << cname << "] ";
|
|---|
| 568 | *fLog << "not yet in " << GetName() << "... creating." << endl;
|
|---|
| 569 |
|
|---|
| 570 | //
|
|---|
| 571 | // try to get class from root environment
|
|---|
| 572 | //
|
|---|
| 573 | *fLog << err;
|
|---|
| 574 | TClass *cls = GetClass(cname, fLog);
|
|---|
| 575 | if (!cls)
|
|---|
| 576 | return NULL;
|
|---|
| 577 |
|
|---|
| 578 | if (!cls->InheritsFrom(MParContainer::Class()))
|
|---|
| 579 | {
|
|---|
| 580 | *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "': " << endl;
|
|---|
| 581 | *fLog << "Class doesn't inherit from MParContainer." << endl;
|
|---|
| 582 | return NULL;
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | //
|
|---|
| 586 | // create the parameter container of the the given class type
|
|---|
| 587 | //
|
|---|
| 588 | pcont = (MParContainer*)cls->New();
|
|---|
| 589 | if (!pcont)
|
|---|
| 590 | {
|
|---|
| 591 | *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "': " << endl;
|
|---|
| 592 | *fLog << " - Class has no default constructor." << endl;
|
|---|
| 593 | *fLog << " - An abstract member functions of a base class is not overwritten." << endl;
|
|---|
| 594 | return NULL;
|
|---|
| 595 | }
|
|---|
| 596 |
|
|---|
| 597 | //
|
|---|
| 598 | // Set the name of the container
|
|---|
| 599 | //
|
|---|
| 600 | pcont->SetName(oname);
|
|---|
| 601 |
|
|---|
| 602 | //
|
|---|
| 603 | // Now add the object to the parameter list
|
|---|
| 604 | //
|
|---|
| 605 | AddToList(pcont);
|
|---|
| 606 |
|
|---|
| 607 | //
|
|---|
| 608 | // The object was automatically created. This makes sure, that such an
|
|---|
| 609 | // object is deleted together with the list
|
|---|
| 610 | //
|
|---|
| 611 | fAutodelete->Add(pcont);
|
|---|
| 612 |
|
|---|
| 613 | //
|
|---|
| 614 | // Find an object in the list.
|
|---|
| 615 | // 'name' is the name of the object you are searching for.
|
|---|
| 616 | //
|
|---|
| 617 | return pcont;
|
|---|
| 618 | }
|
|---|
| 619 |
|
|---|
| 620 | // --------------------------------------------------------------------------
|
|---|
| 621 | //
|
|---|
| 622 | // print some information about the current status of MParList
|
|---|
| 623 | //
|
|---|
| 624 | void MParList::Print(Option_t *) const
|
|---|
| 625 | {
|
|---|
| 626 | *fLog << all << underline << GetDescriptor() << ":" << endl;
|
|---|
| 627 |
|
|---|
| 628 | MParContainer *obj = NULL;
|
|---|
| 629 | MIter Next(fContainer);
|
|---|
| 630 | while ((obj=Next()))
|
|---|
| 631 | {
|
|---|
| 632 | *fLog << " " << obj->GetDescriptor();
|
|---|
| 633 | if (fAutodelete->FindObject(obj))
|
|---|
| 634 | *fLog << " <autodel>";
|
|---|
| 635 | *fLog << endl;
|
|---|
| 636 | }
|
|---|
| 637 | *fLog << endl;
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | // --------------------------------------------------------------------------
|
|---|
| 641 | //
|
|---|
| 642 | // Sets the flags off all containers in the list (and the list
|
|---|
| 643 | // itself) to unchanged
|
|---|
| 644 | //
|
|---|
| 645 | void MParList::SetReadyToSave(Bool_t flag)
|
|---|
| 646 | {
|
|---|
| 647 | fContainer->R__FOR_EACH(MParContainer, SetReadyToSave)(flag);
|
|---|
| 648 | MParContainer::SetReadyToSave(flag);
|
|---|
| 649 | }
|
|---|
| 650 |
|
|---|
| 651 | // --------------------------------------------------------------------------
|
|---|
| 652 | //
|
|---|
| 653 | // Reset all containers in the list
|
|---|
| 654 | //
|
|---|
| 655 | void MParList::Reset()
|
|---|
| 656 | {
|
|---|
| 657 | fContainer->R__FOR_EACH(MParContainer, Reset)();
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | // --------------------------------------------------------------------------
|
|---|
| 661 | //
|
|---|
| 662 | // This finds numbered objects. The objects are returned in a copy of a
|
|---|
| 663 | // TObjArray.
|
|---|
| 664 | //
|
|---|
| 665 | // If from only is given (or to=0) object are assumed numbered
|
|---|
| 666 | // from 1 to from.
|
|---|
| 667 | //
|
|---|
| 668 | TObjArray MParList::FindObjectList(const char *name, UInt_t first, const UInt_t last) const
|
|---|
| 669 | {
|
|---|
| 670 | TObjArray list;
|
|---|
| 671 |
|
|---|
| 672 | if (first>0 && last<first)
|
|---|
| 673 | {
|
|---|
| 674 | *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
|
|---|
| 675 | return list;
|
|---|
| 676 | }
|
|---|
| 677 |
|
|---|
| 678 | const UInt_t len = strlen(name);
|
|---|
| 679 |
|
|---|
| 680 | char *auxname = new char[len+7];
|
|---|
| 681 | strcpy(auxname, name);
|
|---|
| 682 |
|
|---|
| 683 | if (first==0 && last!=0)
|
|---|
| 684 | first = 1;
|
|---|
| 685 |
|
|---|
| 686 | //
|
|---|
| 687 | // If only 'from' is specified the number of entries are ment
|
|---|
| 688 | //
|
|---|
| 689 | for (UInt_t i=first; i<=last; i++)
|
|---|
| 690 | {
|
|---|
| 691 | if (first!=0 || last!=0)
|
|---|
| 692 | sprintf(auxname+len, ";%d", i);
|
|---|
| 693 |
|
|---|
| 694 | TObject *obj = FindObject(auxname);
|
|---|
| 695 | if (!obj)
|
|---|
| 696 | continue;
|
|---|
| 697 |
|
|---|
| 698 | list.AddLast(obj);
|
|---|
| 699 | }
|
|---|
| 700 | delete auxname;
|
|---|
| 701 |
|
|---|
| 702 | return list;
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | // --------------------------------------------------------------------------
|
|---|
| 706 | //
|
|---|
| 707 | // This finds numbered objects. The objects are returned in a copy of a
|
|---|
| 708 | // TObjArray. If one of the objects doesn't exist it is created from the
|
|---|
| 709 | // meaning of cname and oname (s. FindCreateObj)
|
|---|
| 710 | //
|
|---|
| 711 | // If from only is given (or to=0) object are assumed numbered
|
|---|
| 712 | // from 1 to from.
|
|---|
| 713 | //
|
|---|
| 714 | TObjArray MParList::FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
|
|---|
| 715 | {
|
|---|
| 716 | TObjArray list;
|
|---|
| 717 |
|
|---|
| 718 | if (first>0 && last<first)
|
|---|
| 719 | {
|
|---|
| 720 | *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
|
|---|
| 721 | return list;
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | const UInt_t len = strlen(cname);
|
|---|
| 725 |
|
|---|
| 726 | char *auxname = new char[len+7];
|
|---|
| 727 | strcpy(auxname, cname);
|
|---|
| 728 |
|
|---|
| 729 | //
|
|---|
| 730 | // If only 'from' is specified the number of entries are ment
|
|---|
| 731 | //
|
|---|
| 732 | if (first==0 && last!=0)
|
|---|
| 733 | first = 1;
|
|---|
| 734 |
|
|---|
| 735 | for (UInt_t i=first; i<=last; i++)
|
|---|
| 736 | {
|
|---|
| 737 | if (first!=0 || last!=0)
|
|---|
| 738 | sprintf(auxname+len, ";%d", i);
|
|---|
| 739 |
|
|---|
| 740 | TObject *obj = FindCreateObj(auxname, oname);
|
|---|
| 741 | if (!obj)
|
|---|
| 742 | break;
|
|---|
| 743 |
|
|---|
| 744 | list.AddLast(obj);
|
|---|
| 745 | }
|
|---|
| 746 | delete auxname;
|
|---|
| 747 |
|
|---|
| 748 | return list;
|
|---|
| 749 | }
|
|---|
| 750 |
|
|---|
| 751 | // --------------------------------------------------------------------------
|
|---|
| 752 | //
|
|---|
| 753 | // This finds numbered objects. The objects are returned in a copy of a
|
|---|
| 754 | // TObjArray. If one of the objects doesn't exist it is created from the
|
|---|
| 755 | // meaning of cname and oname (s. FindCreateObj)
|
|---|
| 756 | //
|
|---|
| 757 | // If from only is given (or to=0) object are assumed numbered
|
|---|
| 758 | // from 1 to from.
|
|---|
| 759 | //
|
|---|
| 760 | // Remark: Because it is static the object are only created and not added to
|
|---|
| 761 | // the parameter list. You must also take care of deleting these objects!
|
|---|
| 762 | // This function is mainly made for use in root macros. Don't use it in
|
|---|
| 763 | // compiled programs if you are not 100% sure what you are doing.
|
|---|
| 764 | //
|
|---|
| 765 | TObjArray MParList::CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *)
|
|---|
| 766 | {
|
|---|
| 767 | TObjArray list;
|
|---|
| 768 |
|
|---|
| 769 | if (first>0 && last<first)
|
|---|
| 770 | {
|
|---|
| 771 | gLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
|
|---|
| 772 | return list;
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | //
|
|---|
| 776 | // try to get class from root environment
|
|---|
| 777 | //
|
|---|
| 778 | gLog << err;
|
|---|
| 779 | TClass *cls = GetClass(cname, &gLog);
|
|---|
| 780 | if (!cls)
|
|---|
| 781 | return list;
|
|---|
| 782 |
|
|---|
| 783 | if (!cls->InheritsFrom(MParContainer::Class()))
|
|---|
| 784 | {
|
|---|
| 785 | gLog << err << dbginf << "Cannot create new instance of class '" << cname << "': " << endl;
|
|---|
| 786 | gLog << "Class doesn't inherit from MParContainer." << endl;
|
|---|
| 787 | return list;
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 | const UInt_t len = strlen(cname);
|
|---|
| 791 |
|
|---|
| 792 | char *auxname = new char[len+7];
|
|---|
| 793 | strcpy(auxname, cname);
|
|---|
| 794 |
|
|---|
| 795 | //
|
|---|
| 796 | // If only 'from' is specified the number of entries are ment
|
|---|
| 797 | //
|
|---|
| 798 | if (first==0 && last!=0)
|
|---|
| 799 | first = 1;
|
|---|
| 800 |
|
|---|
| 801 | for (UInt_t i=first; i<=last; i++)
|
|---|
| 802 | {
|
|---|
| 803 | if (first!=0 || last!=0)
|
|---|
| 804 | sprintf(auxname+len, ";%d", i);
|
|---|
| 805 |
|
|---|
| 806 | //
|
|---|
| 807 | // create the parameter container of the the given class type
|
|---|
| 808 | //
|
|---|
| 809 | MParContainer *pcont = (MParContainer*)cls->New();
|
|---|
| 810 | if (!pcont)
|
|---|
| 811 | {
|
|---|
| 812 | gLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
|
|---|
| 813 | return list;
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 | //
|
|---|
| 817 | // Set the name of the container
|
|---|
| 818 | //
|
|---|
| 819 | pcont->SetName(auxname);
|
|---|
| 820 |
|
|---|
| 821 | //
|
|---|
| 822 | // Add new object to the return list
|
|---|
| 823 | //
|
|---|
| 824 | list.AddLast(pcont);
|
|---|
| 825 | }
|
|---|
| 826 | delete auxname;
|
|---|
| 827 |
|
|---|
| 828 | return list;
|
|---|
| 829 | }
|
|---|
| 830 |
|
|---|
| 831 | void MParList::SavePrimitive(ostream &out, Option_t *)
|
|---|
| 832 | {
|
|---|
| 833 | Bool_t saved = IsSavedAsPrimitive();
|
|---|
| 834 |
|
|---|
| 835 | MParContainer::SavePrimitive(out);
|
|---|
| 836 |
|
|---|
| 837 | MIter Next(fContainer);
|
|---|
| 838 |
|
|---|
| 839 | MParContainer *cont = NULL;
|
|---|
| 840 | while ((cont=Next()))
|
|---|
| 841 | {
|
|---|
| 842 | //
|
|---|
| 843 | // Because it was automatically created don't store its primitive
|
|---|
| 844 | // I guess it will be automatically created again
|
|---|
| 845 | //
|
|---|
| 846 | if (fAutodelete->FindObject(cont) || cont->IsSavedAsPrimitive())
|
|---|
| 847 | continue;
|
|---|
| 848 |
|
|---|
| 849 | cont->SavePrimitive(out, "");
|
|---|
| 850 |
|
|---|
| 851 | out << " " << GetUniqueName() << ".";
|
|---|
| 852 | out << (cont->InheritsFrom("MTaskList") && saved ? "Replace" : "AddToList");
|
|---|
| 853 | out << "(&" << cont->GetUniqueName() << ");" << endl << endl;
|
|---|
| 854 | }
|
|---|
| 855 | }
|
|---|
| 856 |
|
|---|
| 857 | void MParList::SavePrimitive(ofstream &out, Option_t *o)
|
|---|
| 858 | {
|
|---|
| 859 | SavePrimitive(static_cast<ostream&>(out), o);
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | // --------------------------------------------------------------------------
|
|---|
| 863 | //
|
|---|
| 864 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 865 | // to a macro. In the original root implementation it is used to write
|
|---|
| 866 | // gui elements to a macro-file.
|
|---|
| 867 | //
|
|---|
| 868 | void MParList::StreamPrimitive(ostream &out) const
|
|---|
| 869 | {
|
|---|
| 870 | out << " MParList " << GetUniqueName();
|
|---|
| 871 | if (fName!=gsDefName || fTitle!=gsDefTitle)
|
|---|
| 872 | {
|
|---|
| 873 | out << "(\"" << fName << "\"";
|
|---|
| 874 | if (fTitle!=gsDefTitle)
|
|---|
| 875 | out << ", \"" << fTitle << "\"";
|
|---|
| 876 | out <<")";
|
|---|
| 877 | }
|
|---|
| 878 | out << ";" << endl << endl;
|
|---|
| 879 | }
|
|---|
| 880 |
|
|---|
| 881 | // --------------------------------------------------------------------------
|
|---|
| 882 | //
|
|---|
| 883 | // Adds one TNamed object per object in the list. The TNamed object must
|
|---|
| 884 | // be deleted by the user.
|
|---|
| 885 | //
|
|---|
| 886 | void MParList::GetNames(TObjArray &arr) const
|
|---|
| 887 | {
|
|---|
| 888 | MParContainer::GetNames(arr);
|
|---|
| 889 | fContainer->R__FOR_EACH(MParContainer, GetNames)(arr);
|
|---|
| 890 | }
|
|---|
| 891 |
|
|---|
| 892 | // --------------------------------------------------------------------------
|
|---|
| 893 | //
|
|---|
| 894 | // Sets name and title of each object in the list from the objects in
|
|---|
| 895 | // the array.
|
|---|
| 896 | //
|
|---|
| 897 | void MParList::SetNames(TObjArray &arr)
|
|---|
| 898 | {
|
|---|
| 899 | MParContainer::SetNames(arr);
|
|---|
| 900 | fContainer->R__FOR_EACH(MParContainer, SetNames)(arr);
|
|---|
| 901 | }
|
|---|
| 902 |
|
|---|
| 903 | // --------------------------------------------------------------------------
|
|---|
| 904 | //
|
|---|
| 905 | // Read the contents/setup of a parameter container/task from a TEnv
|
|---|
| 906 | // instance (steering card/setup file).
|
|---|
| 907 | // The key to search for in the file should be of the syntax:
|
|---|
| 908 | // prefix.vname
|
|---|
| 909 | // While vname is a name which is specific for a single setup date
|
|---|
| 910 | // (variable) of this container and prefix is something like:
|
|---|
| 911 | // evtloopname.name
|
|---|
| 912 | // While name is the name of the containers/tasks in the parlist/tasklist
|
|---|
| 913 | //
|
|---|
| 914 | // eg. Job4.MImgCleanStd.CleaningLevel1: 3.0
|
|---|
| 915 | // Job4.MImgCleanStd.CleaningLevel2: 2.5
|
|---|
| 916 | //
|
|---|
| 917 | // If this cannot be found the next step is to search for
|
|---|
| 918 | // MImgCleanStd.CleaningLevel1: 3.0
|
|---|
| 919 | // And if this doesn't exist, too, we search for:
|
|---|
| 920 | // CleaningLevel1: 3.0
|
|---|
| 921 | //
|
|---|
| 922 | // Warning: The programmer is responsible for the names to be unique in
|
|---|
| 923 | // all Mars classes.
|
|---|
| 924 | //
|
|---|
| 925 | Int_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 926 | {
|
|---|
| 927 | if (print)
|
|---|
| 928 | *fLog << all << "MParList::ReadEnv: " << prefix << endl;
|
|---|
| 929 |
|
|---|
| 930 | MParContainer *cont = NULL;
|
|---|
| 931 |
|
|---|
| 932 | MIter Next(fContainer);
|
|---|
| 933 | while ((cont=Next()))
|
|---|
| 934 | {
|
|---|
| 935 | if (cont->InheritsFrom("MTaskList"))
|
|---|
| 936 | {
|
|---|
| 937 | if (cont->ReadEnv(env, prefix, print)==kERROR)
|
|---|
| 938 | return kERROR;
|
|---|
| 939 | continue;
|
|---|
| 940 | }
|
|---|
| 941 |
|
|---|
| 942 | if (cont->TestEnv(env, prefix, print)==kERROR)
|
|---|
| 943 | return kERROR;
|
|---|
| 944 | }
|
|---|
| 945 |
|
|---|
| 946 | return kTRUE;
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | // --------------------------------------------------------------------------
|
|---|
| 950 | //
|
|---|
| 951 | // Write the contents/setup of a parameter container/task to a TEnv
|
|---|
| 952 | // instance (steering card/setup file).
|
|---|
| 953 | // The key to search for in the file should be of the syntax:
|
|---|
| 954 | // prefix.vname
|
|---|
| 955 | // While vname is a name which is specific for a single setup date
|
|---|
| 956 | // (variable) of this container and prefix is something like:
|
|---|
| 957 | // evtloopname.name
|
|---|
| 958 | // While name is the name of the containers/tasks in the parlist/tasklist
|
|---|
| 959 | //
|
|---|
| 960 | // eg. Job4.MImgCleanStd.CleaningLevel1: 3.0
|
|---|
| 961 | // Job4.MImgCleanStd.CleaningLevel2: 2.5
|
|---|
| 962 | //
|
|---|
| 963 | // If this cannot be found the next step is to search for
|
|---|
| 964 | // MImgCleanStd.CleaningLevel1: 3.0
|
|---|
| 965 | // And if this doesn't exist, too, we search for:
|
|---|
| 966 | // CleaningLevel1: 3.0
|
|---|
| 967 | //
|
|---|
| 968 | // Warning: The programmer is responsible for the names to be unique in
|
|---|
| 969 | // all Mars classes.
|
|---|
| 970 | //
|
|---|
| 971 | Bool_t MParList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
|
|---|
| 972 | {
|
|---|
| 973 | MParContainer *cont = NULL;
|
|---|
| 974 |
|
|---|
| 975 | MIter Next(fContainer);
|
|---|
| 976 | while ((cont=Next()))
|
|---|
| 977 | if (!cont->WriteEnv(env, prefix, print))
|
|---|
| 978 | return kFALSE;
|
|---|
| 979 | return kTRUE;
|
|---|
| 980 | }
|
|---|
| 981 |
|
|---|
| 982 | // --------------------------------------------------------------------------
|
|---|
| 983 | //
|
|---|
| 984 | // Can be used to create an iterator over all containers, eg:
|
|---|
| 985 | // MParList plist;
|
|---|
| 986 | // TIter Next(plist); // Be aware: Use a object here rather than a pointer!
|
|---|
| 987 | // TObject *o=0;
|
|---|
| 988 | // while ((o=Next()))
|
|---|
| 989 | // {
|
|---|
| 990 | // [...]
|
|---|
| 991 | // }
|
|---|
| 992 | //
|
|---|
| 993 | MParList::operator TIterator*() const
|
|---|
| 994 | {
|
|---|
| 995 | return new TOrdCollectionIter(fContainer);
|
|---|
| 996 | }
|
|---|