source: branches/start/MagicSoft/MarsOctober/mbase/MParList.cc@ 9223

Last change on this file since 9223 was 447, checked in by harald, 24 years ago
Bringing the sources for the octobertest under CVS controll. (november, 3rd, 2000)
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1///////////////////////////////////////////////////////////////////////
2//
3// MParList
4//
5// This class contains a list of different Parameter and Data
6// Containers.
7//
8// You can add every parameter Container (Named object) to the
9// instance and access it from somewhere else via its Name.
10//
11///////////////////////////////////////////////////////////////////////
12
13#include "MParList.h"
14
15#include "MParContainer.h"
16
17ClassImp(MParList)
18
19MParList::MParList() : fNext(NULL)
20{
21 //
22 // default constructor
23 // creates an empty list
24 //
25
26}
27
28MParList::MParList(MParList &ts)
29{
30 //
31 // copy constructor
32 //
33
34 fContainer.AddAll(&ts.fContainer);
35}
36
37Bool_t MParList::ReInit(MParList *pList)
38{
39 //
40 // do a reinitialisation of all containers in this list (eg resizining)
41 // return kFALSE if a problem occured, else return kFALSE
42 //
43 cout << "Reinitializing... " << flush;
44
45 if (!pList)
46 pList = this;
47
48 //
49 // create the Iterator over the list
50 //
51 TIter next(&fContainer);
52
53 MParContainer *pCont;
54
55 //
56 // loop over all containers in the list
57 //
58 while ((pCont=(MParContainer *)next()))
59 {
60 if (pCont->IsBuffer())
61 //
62 // FIXME: Here we have to loop over all entries in the buffer
63 //
64 continue;
65
66 cout << pCont->GetName() << "... " << flush;
67
68 if (!pCont->ReInit(pList))
69 return kFALSE;
70 }
71
72 cout << endl;
73
74 return kTRUE;
75}
76
77Bool_t MParList::AddToList(MParContainer *obj, TNamed *where)
78{
79 //
80 // Add an Container to the list.
81 //
82 // If 'where' is given, the object will be added after this.
83 //
84
85 //
86 // check if the object (you want to add) exists
87 //
88 if (!obj) return kTRUE;
89
90 cout << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush;
91 //
92 // check if it is in the list yet
93 //
94 if (fContainer.FindObject(obj))
95 {
96 cout << "WARNING: MParList::add: Container already added" << endl;
97 return kTRUE;
98 }
99
100 //
101 // check if you want to add the new parameter container somewhere
102 // special (in that case you specify "where")
103 //
104 if (where)
105 {
106 if (!fContainer.FindObject(where))
107 {
108 cout << "ERROR: MParList::add: Cannot find parameter container after which the new one should be added!" << endl;
109 return kFALSE;
110 }
111 }
112
113 fContainer.Add(obj);
114 cout << "Done." << endl;
115
116 return kTRUE;
117}
118
119MParContainer *MParList::FindObject(const char *name)
120{
121 //
122 // Find an object in the list.
123 // 'name' is the name of the object you are searching for.
124 //
125 return (MParContainer*)fContainer.FindObject(name);
126}
127
128
129void MParList::Print(Option_t *t)
130{
131 //
132 // print some information about the current status of MParList
133 //
134 cout << "ParList: " << this->GetName() << " <" << this->GetTitle() << ">" << endl;
135 cout << endl;
136}
137
Note: See TracBrowser for help on using the repository browser.