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