Logo ROOT   6.14/05
Reference Guide
TObjectSet.cxx
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@bnl.gov) 25/12/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TObjectSet.h"
13 #include "TBrowser.h"
14 
16 
17 //////////////////////////////////////////////////////////////////////////////////////
18 // //
19 // TObjectSet - is a container TDataSet //
20 // This means this object has an extra pointer to an embedded //
21 // TObject. //
22 // Terminology: This TObjectSet may be an OWNER of the embeded TObject //
23 // If the container is the owner it can delete the embeded object //
24 // otherwsie it leaves that object "as is" //
25 // //
26 //////////////////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 ///to be documented
30 
31 TObjectSet::TObjectSet(const Char_t *name, TObject *obj, Bool_t makeOwner):TDataSet(name)
32 {
33  SetTitle("TObjectSet");
34  SetObject(obj,makeOwner);
35 }
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 ///to be documented
39 
40 TObjectSet::TObjectSet(TObject *obj,Bool_t makeOwner) : TDataSet("unknown","TObjectSet")
41 {
42  SetObject(obj,makeOwner);
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 ///to be documented
47 
49 {
50  if (fObj && IsOwner() && (TObject::TestBit(kNotDeleted)) ) delete fObj;
51  fObj = 0;
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Aliase for SetObject method
56 
58 {
59  return SetObject(obj,makeOwner);
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Browse this dataset (called by TBrowser).
64 
66 {
67  if (b && fObj) b->Add(fObj);
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 ///to be documented
73 
75 {
76  if (opt) {/* no used */}
77  if (fObj && IsOwner()) delete fObj;
78  fObj = 0;
80 }
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Set / Reset the ownerships and returns the previous
83 /// status of the ownerships.
84 
86 {
87  Bool_t own = IsOwner();
88  if (own != done) {
89  if (done) SetBit(kIsOwner);
90  else ResetBit(kIsOwner);
91  }
92  return own;
93 }
94 ////////////////////////////////////////////////////////////////////////////////
95 /// apply the class default ctor to instantiate a new object of the same kind.
96 /// This is a base method to be overriden by the classes
97 /// derived from TDataSet (to support TDataSetIter::Mkdir for example)
98 
100 {
101  return instance();
102 }
103 ////////////////////////////////////////////////////////////////////////////////
104 /// - Replace the embedded object with a new supplied
105 /// - Destroy the preivous embedded object if this is its owner
106 /// - Return the previous embedded object if any
107 
109 {
110  TObject *oldObject = fObj;
111  if (IsOwner()) { delete oldObject; oldObject = 0;} // the object has been killed
112  fObj = obj;
113  DoOwner(makeOwner);
114  return oldObject;
115 }
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
virtual TObject * AddObject(TObject *obj, Bool_t makeOwner=kTRUE)
Aliase for SetObject method.
Definition: TObjectSet.cxx:57
virtual TDataSet * Instance() const
apply the class default ctor to instantiate a new object of the same kind.
Definition: TObjectSet.cxx:99
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t DoOwner(Bool_t done=kTRUE)
Set / Reset the ownerships and returns the previous status of the ownerships.
Definition: TObjectSet.cxx:85
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
bool Bool_t
Definition: RtypesCore.h:59
virtual void Delete(Option_t *opt="")
Delete - deletes the list of the TDataSet objects and all "Structural Members" as well This method do...
Definition: TDataSet.cxx:320
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TDataSet.cxx:297
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
TObjectSet(const Char_t *name, TObject *obj=0, Bool_t makeOwner=kTRUE)
to be documented
Definition: TObjectSet.cxx:31
TObject * fObj
Definition: TObjectSet.h:30
virtual void Delete(Option_t *opt="")
to be documented
Definition: TObjectSet.cxx:74
object has not been deleted
Definition: TObject.h:78
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:59
static TObjectSet * instance()
Definition: TObjectSet.h:52
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TObjectSet.cxx:65
Mother of all ROOT objects.
Definition: TObject.h:37
char Char_t
Definition: RtypesCore.h:29
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual Bool_t IsOwner() const
Definition: TObjectSet.h:57
void ResetBit(UInt_t f)
Definition: TObject.h:171
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
char name[80]
Definition: TGX11.cxx:109
virtual ~TObjectSet()
to be documented
Definition: TObjectSet.cxx:48