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