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