1 | ///////////////////////////////////////////////////////////////////////////
|
---|
2 | // //
|
---|
3 | // MParContainer //
|
---|
4 | // //
|
---|
5 | // The MParContainer class is the base class for all MARS parameter //
|
---|
6 | // containers. At the moment it is almost the same than ROOT's TNamed. //
|
---|
7 | // A TNamed contains the essential elements (name, title) //
|
---|
8 | // to identify a derived object in lists like our MParList or MTaskList. //
|
---|
9 | // The main difference is that the name and title isn't stored and read //
|
---|
10 | // to and from root files ("\\!") //
|
---|
11 | // //
|
---|
12 | //////////////////////////////////////////////////////////////////////////
|
---|
13 | #include "MParContainer.h"
|
---|
14 |
|
---|
15 | #include <iostream.h> // cout
|
---|
16 |
|
---|
17 | #include <TClass.h> // IsA
|
---|
18 | #include <TROOT.h> // TROOT::Identlevel
|
---|
19 | #include <TVirtualPad.h> // gPad
|
---|
20 |
|
---|
21 | ClassImp(MParContainer)
|
---|
22 |
|
---|
23 | //______________________________________________________________________________
|
---|
24 | MParContainer::MParContainer(const MParContainer &named)
|
---|
25 | {
|
---|
26 | // MParContainer copy ctor.
|
---|
27 |
|
---|
28 | *fName = *(named.fName);
|
---|
29 | *fTitle = *(named.fTitle);
|
---|
30 | }
|
---|
31 |
|
---|
32 | //______________________________________________________________________________
|
---|
33 | MParContainer& MParContainer::operator=(const MParContainer& rhs)
|
---|
34 | {
|
---|
35 | // MParContainer assignment operator.
|
---|
36 |
|
---|
37 | if (this != &rhs) {
|
---|
38 | TObject::operator=(rhs);
|
---|
39 | *fName = *(rhs.fName);
|
---|
40 | *fTitle = *(rhs.fTitle);
|
---|
41 | }
|
---|
42 | return *this;
|
---|
43 | }
|
---|
44 |
|
---|
45 | //______________________________________________________________________________
|
---|
46 | Int_t MParContainer::Compare(TObject *obj)
|
---|
47 | {
|
---|
48 | // Compare two MParContainer objects. Returns 0 when equal, -1 when this is
|
---|
49 | // smaller and +1 when bigger (like strcmp).
|
---|
50 |
|
---|
51 | if (this == obj) return 0;
|
---|
52 | return fName->CompareTo(obj->GetName());
|
---|
53 | }
|
---|
54 |
|
---|
55 | //______________________________________________________________________________
|
---|
56 | void MParContainer::Copy(TObject &obj)
|
---|
57 | {
|
---|
58 | // Copy this to obj.
|
---|
59 |
|
---|
60 | TObject::Copy(obj);
|
---|
61 | *(((MParContainer&)obj).fName) = *fName;
|
---|
62 | *(((MParContainer&)obj).fTitle) = *fTitle;
|
---|
63 | }
|
---|
64 |
|
---|
65 | //______________________________________________________________________________
|
---|
66 | void MParContainer::FillBuffer(char *&buffer)
|
---|
67 | {
|
---|
68 | // Encode MParContainer into output buffer.
|
---|
69 |
|
---|
70 | fName->FillBuffer(buffer);
|
---|
71 | fTitle->FillBuffer(buffer);
|
---|
72 | }
|
---|
73 |
|
---|
74 | //______________________________________________________________________________
|
---|
75 | void MParContainer::ls(Option_t *)
|
---|
76 | {
|
---|
77 | // List MParContainer name and title.
|
---|
78 |
|
---|
79 | TROOT::IndentLevel();
|
---|
80 | cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << " : "
|
---|
81 | << Int_t(TestBit(kCanDelete)) << endl;
|
---|
82 | }
|
---|
83 |
|
---|
84 | //______________________________________________________________________________
|
---|
85 | void MParContainer::Print(Option_t *)
|
---|
86 | {
|
---|
87 | // Print MParContainer name and title.
|
---|
88 |
|
---|
89 | cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << endl;
|
---|
90 | }
|
---|
91 |
|
---|
92 | //______________________________________________________________________________
|
---|
93 | void MParContainer::SetName(const char *name)
|
---|
94 | {
|
---|
95 | // Change (i.e. set) the name of the MParContainer.
|
---|
96 | // WARNING !!
|
---|
97 | // If the object is a member of a THashTable, THashList container
|
---|
98 | // The HashTable must be Rehashed after SetName
|
---|
99 | // For example the list of objects in the current directory is a THashList
|
---|
100 |
|
---|
101 | *fName = name;
|
---|
102 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
---|
103 | }
|
---|
104 |
|
---|
105 | //______________________________________________________________________________
|
---|
106 | void MParContainer::SetObject(const char *name, const char *title)
|
---|
107 | {
|
---|
108 | // Change (i.e. set) all the MParContainer parameters (name and title).
|
---|
109 | // See also WARNING in SetName
|
---|
110 |
|
---|
111 | *fName = name;
|
---|
112 | *fTitle = title;
|
---|
113 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
---|
114 | }
|
---|
115 |
|
---|
116 | //______________________________________________________________________________
|
---|
117 | void MParContainer::SetTitle(const char *title)
|
---|
118 | {
|
---|
119 | // Change (i.e. set) the title of the MParContainer.
|
---|
120 |
|
---|
121 | *fTitle = title;
|
---|
122 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
---|
123 | }
|
---|
124 |
|
---|
125 | //______________________________________________________________________________
|
---|
126 | Int_t MParContainer::Sizeof() const
|
---|
127 | {
|
---|
128 | // Return size of the MParContainer part of the TObject.
|
---|
129 |
|
---|
130 | Int_t nbytes = fName->Sizeof() + fTitle->Sizeof();
|
---|
131 | return nbytes;
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|