source: trunk/MagicSoft/Mars/mbase/MParContainer.cc@ 454

Last change on this file since 454 was 454, checked in by harald, 24 years ago
Import the first sources of the MAGIC Analysis and Reconstruction Software. T. Bretz and H. Kornmayer 20.December 2000
File size: 4.2 KB
Line 
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
20ClassImp(MParContainer)
21
22//______________________________________________________________________________
23MParContainer::MParContainer(const MParContainer &named)
24{
25 // TNamed copy ctor.
26
27 *fName = *(named.fName);
28 *fTitle = *(named.fTitle);
29}
30
31//______________________________________________________________________________
32MParContainer& 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//______________________________________________________________________________
45Int_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//______________________________________________________________________________
55void 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//______________________________________________________________________________
65void MParContainer::FillBuffer(char *&buffer)
66{
67 // Encode TNamed into output buffer.
68
69 fName->FillBuffer(buffer);
70 fTitle->FillBuffer(buffer);
71}
72
73//______________________________________________________________________________
74void 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//______________________________________________________________________________
84void 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//______________________________________________________________________________
92void 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//______________________________________________________________________________
105void 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//______________________________________________________________________________
116void 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//______________________________________________________________________________
125Int_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
Note: See TracBrowser for help on using the repository browser.