StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TObjectSet.cxx
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 
15 ClassImp(TObjectSet);
16 
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 // //
27 
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 
39 
40 TObjectSet::TObjectSet(TObject *obj,Bool_t makeOwner) : TDataSet("unknown","TObjectSet")
41 {
42  SetObject(obj,makeOwner);
43 }
44 
47 
49 {
50  if (fObj && IsOwner() && (TObject::TestBit(kNotDeleted)) ) delete fObj;
51  fObj = 0;
52 }
53 
56 
57 TObject *TObjectSet::AddObject(TObject *obj,Bool_t makeOwner)
58 {
59  return SetObject(obj,makeOwner);
60 }
61 
64 
65 void TObjectSet::Browse(TBrowser *b)
66 {
67  if (b && fObj) b->Add(fObj);
69 }
70 
73 
74 void TObjectSet::Delete(Option_t *opt)
75 {
76  if (opt) {/* no used */}
77  if (fObj && IsOwner()) delete fObj;
78  fObj = 0;
80 }
84 
85 Bool_t TObjectSet::DoOwner(Bool_t done)
86 {
87  Bool_t own = IsOwner();
88  if (own != done) {
89  if (done) SetBit(kIsOwner);
90  else ResetBit(kIsOwner);
91  }
92  return own;
93 }
98 
100 {
101  return instance();
102 }
107 
108 TObject *TObjectSet::SetObject(TObject *obj,Bool_t makeOwner)
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 }
virtual TObject * AddObject(TObject *obj, Bool_t makeOwner=kTRUE)
Aliase for SetObject method.
Definition: TObjectSet.cxx:57
virtual Bool_t DoOwner(Bool_t done=kTRUE)
Definition: TObjectSet.cxx:85
virtual void Delete(Option_t *opt="")
Definition: TDataSet.cxx:320
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TDataSet.cxx:297
TObjectSet(const Char_t *name, TObject *obj=0, Bool_t makeOwner=kTRUE)
to be documented
Definition: TObjectSet.cxx:31
virtual void Delete(Option_t *opt="")
to be documented
Definition: TObjectSet.cxx:74
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:59
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TObjectSet.cxx:65
virtual TDataSet * Instance() const
Definition: TObjectSet.cxx:99
virtual ~TObjectSet()
to be documented
Definition: TObjectSet.cxx:48