| 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 | *fName = *(named.fName);
|
|---|
| 27 | *fTitle = *(named.fTitle);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | //______________________________________________________________________________
|
|---|
| 31 | MParContainer& MParContainer::operator=(const MParContainer& rhs)
|
|---|
| 32 | {
|
|---|
| 33 | // TNamed assignment operator.
|
|---|
| 34 |
|
|---|
| 35 | if (this != &rhs) {
|
|---|
| 36 | TObject::operator=(rhs);
|
|---|
| 37 | *fName = *(rhs.fName);
|
|---|
| 38 | *fTitle = *(rhs.fTitle);
|
|---|
| 39 | }
|
|---|
| 40 | return *this;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | //______________________________________________________________________________
|
|---|
| 44 | Int_t MParContainer::Compare(TObject *obj)
|
|---|
| 45 | {
|
|---|
| 46 | // Compare two TNamed objects. Returns 0 when equal, -1 when this is
|
|---|
| 47 | // smaller and +1 when bigger (like strcmp).
|
|---|
| 48 |
|
|---|
| 49 | if (this == obj) return 0;
|
|---|
| 50 | return fName->CompareTo(obj->GetName());
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | //______________________________________________________________________________
|
|---|
| 54 | void MParContainer::Copy(TObject &obj)
|
|---|
| 55 | {
|
|---|
| 56 | // Copy this to obj.
|
|---|
| 57 |
|
|---|
| 58 | TObject::Copy(obj);
|
|---|
| 59 | *(((MParContainer&)obj).fName) = *fName;
|
|---|
| 60 | *(((MParContainer&)obj).fTitle) = *fTitle;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | //______________________________________________________________________________
|
|---|
| 64 | void MParContainer::FillBuffer(char *&buffer)
|
|---|
| 65 | {
|
|---|
| 66 | // Encode TNamed into output buffer.
|
|---|
| 67 |
|
|---|
| 68 | fName->FillBuffer(buffer);
|
|---|
| 69 | fTitle->FillBuffer(buffer);
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | //______________________________________________________________________________
|
|---|
| 73 | void MParContainer::ls(Option_t *)
|
|---|
| 74 | {
|
|---|
| 75 | // List TNamed name and title.
|
|---|
| 76 |
|
|---|
| 77 | TROOT::IndentLevel();
|
|---|
| 78 | cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << " : "
|
|---|
| 79 | << Int_t(TestBit(kCanDelete)) << endl;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | //______________________________________________________________________________
|
|---|
| 83 | void MParContainer::Print(Option_t *)
|
|---|
| 84 | {
|
|---|
| 85 | // Print TNamed name and title.
|
|---|
| 86 |
|
|---|
| 87 | cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << endl;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | //______________________________________________________________________________
|
|---|
| 91 | void MParContainer::SetName(const char *name)
|
|---|
| 92 | {
|
|---|
| 93 | // Change (i.e. set) the name of the TNamed.
|
|---|
| 94 | // WARNING !!
|
|---|
| 95 | // If the object is a member of a THashTable, THashList container
|
|---|
| 96 | // The HashTable must be Rehashed after SetName
|
|---|
| 97 | // For example the list of objects in the current directory is a THashList
|
|---|
| 98 |
|
|---|
| 99 | *fName = name;
|
|---|
| 100 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | //______________________________________________________________________________
|
|---|
| 104 | void MParContainer::SetObject(const char *name, const char *title)
|
|---|
| 105 | {
|
|---|
| 106 | // Change (i.e. set) all the TNamed parameters (name and title).
|
|---|
| 107 | // See also WARNING in SetName
|
|---|
| 108 |
|
|---|
| 109 | *fName = name;
|
|---|
| 110 | *fTitle = title;
|
|---|
| 111 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | //______________________________________________________________________________
|
|---|
| 115 | void MParContainer::SetTitle(const char *title)
|
|---|
| 116 | {
|
|---|
| 117 | // Change (i.e. set) the title of the TNamed.
|
|---|
| 118 |
|
|---|
| 119 | *fTitle = title;
|
|---|
| 120 | if (gPad && TestBit(kMustCleanup)) gPad->Modified();
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | //______________________________________________________________________________
|
|---|
| 124 | Int_t MParContainer::Sizeof() const
|
|---|
| 125 | {
|
|---|
| 126 | // Return size of the TNamed part of the TObject.
|
|---|
| 127 |
|
|---|
| 128 | Int_t nbytes = fName->Sizeof() + fTitle->Sizeof();
|
|---|
| 129 | return nbytes;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|