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

Last change on this file since 812 was 752, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.3 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26// //
27// MParContainer //
28// //
29// The MParContainer class is the base class for all MARS parameter //
30// containers. At the moment it is almost the same than ROOT's TNamed. //
31// A TNamed contains the essential elements (name, title) //
32// to identify a derived object in lists like our MParList or MTaskList. //
33// The main difference is that the name and title isn't stored and read //
34// to and from root files ("//!") //
35// //
36//////////////////////////////////////////////////////////////////////////////
37#include "MParContainer.h"
38
39#include <TClass.h> // IsA
40#include <TROOT.h> // TROOT::Identlevel
41#include <TVirtualPad.h> // gPad
42
43#include "MLog.h"
44
45ClassImp(MParContainer);
46
47// --------------------------------------------------------------------------
48//
49// MParContainer copy ctor
50//
51MParContainer::MParContainer(const MParContainer &named)
52{
53 *fName = *(named.fName);
54 *fTitle = *(named.fTitle);
55}
56
57// --------------------------------------------------------------------------
58//
59// MParContainer assignment operator.
60//
61MParContainer& MParContainer::operator=(const MParContainer& rhs)
62{
63 if (this != &rhs) {
64 TObject::operator=(rhs);
65 *fName = *(rhs.fName);
66 *fTitle = *(rhs.fTitle);
67 }
68 return *this;
69}
70
71// --------------------------------------------------------------------------
72//
73// Compare two MParContainer objects. Returns 0 when equal, -1 when this is
74// smaller and +1 when bigger (like strcmp).
75//
76Int_t MParContainer::Compare(TObject *obj)
77{
78 if (this == obj) return 0;
79 return fName->CompareTo(obj->GetName());
80}
81
82// --------------------------------------------------------------------------
83//
84// Copy this to obj.
85//
86void MParContainer::Copy(TObject &obj)
87{
88 TObject::Copy(obj);
89 *(((MParContainer&)obj).fName) = *fName;
90 *(((MParContainer&)obj).fTitle) = *fTitle;
91}
92
93// --------------------------------------------------------------------------
94//
95// Encode MParContainer into output buffer.
96//
97void MParContainer::FillBuffer(char *&buffer)
98{
99 fName->FillBuffer(buffer);
100 fTitle->FillBuffer(buffer);
101}
102
103// --------------------------------------------------------------------------
104//
105// List MParContainer name and title.
106//
107void MParContainer::ls(Option_t *)
108{
109 TROOT::IndentLevel();
110 *fLog <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << " : "
111 << Int_t(TestBit(kCanDelete)) << endl;
112}
113
114// --------------------------------------------------------------------------
115//
116// Print MParContainer name and title.
117//
118void MParContainer::Print(Option_t *)
119{
120 *fLog <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << endl;
121}
122
123// --------------------------------------------------------------------------
124//
125// Change (i.e. set) the name of the MParContainer.
126// WARNING !!
127// If the object is a member of a THashTable, THashList container
128// The HashTable must be Rehashed after SetName
129// For example the list of objects in the current directory is a THashList
130//
131void MParContainer::SetName(const char *name)
132{
133 *fName = name;
134 if (gPad && TestBit(kMustCleanup)) gPad->Modified();
135}
136
137// --------------------------------------------------------------------------
138//
139// Change (i.e. set) all the MParContainer parameters (name and title).
140// See also WARNING in SetName
141//
142void MParContainer::SetObject(const char *name, const char *title)
143{
144 *fName = name;
145 *fTitle = title;
146 if (gPad && TestBit(kMustCleanup)) gPad->Modified();
147}
148
149// --------------------------------------------------------------------------
150//
151// Change (i.e. set) the title of the MParContainer.
152//
153void MParContainer::SetTitle(const char *title)
154{
155 *fTitle = title;
156 if (gPad && TestBit(kMustCleanup)) gPad->Modified();
157}
158
159// --------------------------------------------------------------------------
160//
161// Return size of the MParContainer part of the TObject.
162//
163Int_t MParContainer::Sizeof() const
164{
165 Int_t nbytes = fName->Sizeof() + fTitle->Sizeof();
166 return nbytes;
167}
Note: See TracBrowser for help on using the repository browser.