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