source: trunk/MagicSoft/Mars/mbase/MParList.cc@ 2470

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