1 | /////////////////////////////////////////////////////////////////////////////
|
---|
2 | // //
|
---|
3 | // MParList //
|
---|
4 | // //
|
---|
5 | // This class contains a list of different parameter containers. //
|
---|
6 | // //
|
---|
7 | // A parameter container is an object which is derived from //
|
---|
8 | // MParContainer. //
|
---|
9 | // //
|
---|
10 | // Normally a parameter container is used for data exchange between two //
|
---|
11 | // tasks at runtime. //
|
---|
12 | // //
|
---|
13 | // You can add every parameter container (Named object) to the //
|
---|
14 | // instance and access it from somewhere else via its Name. //
|
---|
15 | // //
|
---|
16 | /////////////////////////////////////////////////////////////////////////////
|
---|
17 | #include "MParList.h"
|
---|
18 |
|
---|
19 | #include <TNamed.h>
|
---|
20 |
|
---|
21 | #include "MLog.h"
|
---|
22 |
|
---|
23 | ClassImp(MParList)
|
---|
24 |
|
---|
25 | MParList::MParList() : fNext(NULL)
|
---|
26 | {
|
---|
27 | //
|
---|
28 | // default constructor
|
---|
29 | // creates an empty list
|
---|
30 | //
|
---|
31 |
|
---|
32 | }
|
---|
33 |
|
---|
34 | MParList::MParList(MParList &ts)
|
---|
35 | {
|
---|
36 | //
|
---|
37 | // copy constructor
|
---|
38 | //
|
---|
39 |
|
---|
40 | fContainer.AddAll(&ts.fContainer);
|
---|
41 | }
|
---|
42 |
|
---|
43 | void MParList::SetLogStream(MLog *log)
|
---|
44 | {
|
---|
45 | //
|
---|
46 | // create the Iterator over the tasklist
|
---|
47 | //
|
---|
48 | TIter Next(&fContainer);
|
---|
49 |
|
---|
50 | MParContainer *cont=NULL;
|
---|
51 |
|
---|
52 | //
|
---|
53 | // loop over all tasks for preproccesing
|
---|
54 | //
|
---|
55 | while ( (cont=(MParContainer*)Next()) )
|
---|
56 | cont->SetLogStream(log);
|
---|
57 |
|
---|
58 | MParContainer::SetLogStream(log);
|
---|
59 | }
|
---|
60 |
|
---|
61 | Bool_t MParList::AddToList(MParContainer *obj, MParContainer *where)
|
---|
62 | {
|
---|
63 | //
|
---|
64 | // Add an Container to the list.
|
---|
65 | //
|
---|
66 | // If 'where' is given, the object will be added after this.
|
---|
67 | //
|
---|
68 |
|
---|
69 | //
|
---|
70 | // check if the object (you want to add) exists
|
---|
71 | //
|
---|
72 |
|
---|
73 | if (!obj) return kTRUE;
|
---|
74 |
|
---|
75 | *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush;
|
---|
76 | //
|
---|
77 | // check if it is in the list yet
|
---|
78 | //
|
---|
79 | if (fContainer.FindObject(obj))
|
---|
80 | {
|
---|
81 | *fLog << "WARNING: MParList::add: Container already added" << endl;
|
---|
82 | return kTRUE;
|
---|
83 | }
|
---|
84 |
|
---|
85 | //
|
---|
86 | // check if you want to add the new parameter container somewhere
|
---|
87 | // special (in that case you specify "where")
|
---|
88 | //
|
---|
89 | if (where)
|
---|
90 | {
|
---|
91 | if (!fContainer.FindObject(where))
|
---|
92 | {
|
---|
93 | *fLog << "ERROR: MParList::add: Cannot find parameter container after which the new one should be added!" << endl;
|
---|
94 | return kFALSE;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | fContainer.Add(obj);
|
---|
99 | *fLog << "Done." << endl;
|
---|
100 |
|
---|
101 | return kTRUE;
|
---|
102 | }
|
---|
103 |
|
---|
104 | TObject *MParList::FindObject(const char *name) const
|
---|
105 | {
|
---|
106 | //
|
---|
107 | // Find an object in the list.
|
---|
108 | // 'name' is the name of the object you are searching for.
|
---|
109 | //
|
---|
110 | return (TObject*)fContainer.FindObject(name);
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | void MParList::Print(Option_t *t)
|
---|
115 | {
|
---|
116 | //
|
---|
117 | // print some information about the current status of MParList
|
---|
118 | //
|
---|
119 | *fLog << "ParList: " << this->GetName() << " <" << this->GetTitle() << ">" << endl;
|
---|
120 | *fLog << endl;
|
---|
121 |
|
---|
122 | }
|
---|
123 |
|
---|