ROOT logo
// @(#)root/table:$Id: TObjectSet.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Valery Fine(fine@bnl.gov)   25/12/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TObjectSet.h"
#include "TBrowser.h"

ClassImp(TObjectSet)

//////////////////////////////////////////////////////////////////////////////////////
//                                                                                  //
//  TObjectSet  - is a container TDataSet                                           //
//                  This means this object has an extra pointer to an embedded      //
//                  TObject.                                                        //
//  Terminology:    This TObjectSet may be an OWNER of the embeded TObject          //
//                  If the container is the owner it can delete the embeded object  //
//                  otherwsie it leaves that object "as is"                         //
//                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////

//_____________________________________________________________________________
TObjectSet::TObjectSet(const Char_t *name, TObject *obj, Bool_t makeOwner):TDataSet(name)
{
   //to be documented
   SetTitle("TObjectSet");
   SetObject(obj,makeOwner);
}

//_____________________________________________________________________________
TObjectSet::TObjectSet(TObject *obj,Bool_t makeOwner) : TDataSet("unknown","TObjectSet")
{
   //to be documented
   SetObject(obj,makeOwner);
}

//_____________________________________________________________________________
TObjectSet::~TObjectSet()
{
   //to be documented
   if (fObj && IsOwner() && (TObject::TestBit(kNotDeleted))  ) delete fObj;
   fObj = 0;
}

//______________________________________________________________________________
TObject *TObjectSet::AddObject(TObject *obj,Bool_t makeOwner)
{
   // Aliase for SetObject method
   return SetObject(obj,makeOwner);
}

//______________________________________________________________________________
void TObjectSet::Browse(TBrowser *b)
{
   // Browse this dataset (called by TBrowser).
   if (b && fObj) b->Add(fObj);
   TDataSet::Browse(b);
}

//_____________________________________________________________________________
void TObjectSet::Delete(Option_t *opt)
{
   //to be documented
   if (opt) {/* no used */}
   if (fObj && IsOwner()) delete fObj;
   fObj = 0;
   TDataSet::Delete();
}
//______________________________________________________________________________
Bool_t TObjectSet::DoOwner(Bool_t done)
{
  // Set / Reset the ownerships and returns the previous
  // status of the ownerships.

   Bool_t own = IsOwner();
   if (own != done) {
      if (done) SetBit(kIsOwner);
      else ResetBit(kIsOwner);
   }
   return own;
}
//______________________________________________________________________________
TDataSet *TObjectSet::Instance() const
{
   // apply the class default ctor to instantiate a new object of the same kind.
   // This is a base method to be overriden by the classes
   // derived from TDataSet (to support TDataSetIter::Mkdir for example)
   return instance();
}
//______________________________________________________________________________
TObject *TObjectSet::SetObject(TObject *obj,Bool_t makeOwner)
{
   // - Replace the embedded object with a new supplied
   // - Destroy the preivous embedded object if this is its owner
   // - Return the previous embedded object if any

   TObject *oldObject = fObj;
   if (IsOwner()) { delete oldObject; oldObject = 0;} // the object has been killed
   fObj = obj;
   DoOwner(makeOwner);
   return oldObject;
}
 TObjectSet.cxx:1
 TObjectSet.cxx:2
 TObjectSet.cxx:3
 TObjectSet.cxx:4
 TObjectSet.cxx:5
 TObjectSet.cxx:6
 TObjectSet.cxx:7
 TObjectSet.cxx:8
 TObjectSet.cxx:9
 TObjectSet.cxx:10
 TObjectSet.cxx:11
 TObjectSet.cxx:12
 TObjectSet.cxx:13
 TObjectSet.cxx:14
 TObjectSet.cxx:15
 TObjectSet.cxx:16
 TObjectSet.cxx:17
 TObjectSet.cxx:18
 TObjectSet.cxx:19
 TObjectSet.cxx:20
 TObjectSet.cxx:21
 TObjectSet.cxx:22
 TObjectSet.cxx:23
 TObjectSet.cxx:24
 TObjectSet.cxx:25
 TObjectSet.cxx:26
 TObjectSet.cxx:27
 TObjectSet.cxx:28
 TObjectSet.cxx:29
 TObjectSet.cxx:30
 TObjectSet.cxx:31
 TObjectSet.cxx:32
 TObjectSet.cxx:33
 TObjectSet.cxx:34
 TObjectSet.cxx:35
 TObjectSet.cxx:36
 TObjectSet.cxx:37
 TObjectSet.cxx:38
 TObjectSet.cxx:39
 TObjectSet.cxx:40
 TObjectSet.cxx:41
 TObjectSet.cxx:42
 TObjectSet.cxx:43
 TObjectSet.cxx:44
 TObjectSet.cxx:45
 TObjectSet.cxx:46
 TObjectSet.cxx:47
 TObjectSet.cxx:48
 TObjectSet.cxx:49
 TObjectSet.cxx:50
 TObjectSet.cxx:51
 TObjectSet.cxx:52
 TObjectSet.cxx:53
 TObjectSet.cxx:54
 TObjectSet.cxx:55
 TObjectSet.cxx:56
 TObjectSet.cxx:57
 TObjectSet.cxx:58
 TObjectSet.cxx:59
 TObjectSet.cxx:60
 TObjectSet.cxx:61
 TObjectSet.cxx:62
 TObjectSet.cxx:63
 TObjectSet.cxx:64
 TObjectSet.cxx:65
 TObjectSet.cxx:66
 TObjectSet.cxx:67
 TObjectSet.cxx:68
 TObjectSet.cxx:69
 TObjectSet.cxx:70
 TObjectSet.cxx:71
 TObjectSet.cxx:72
 TObjectSet.cxx:73
 TObjectSet.cxx:74
 TObjectSet.cxx:75
 TObjectSet.cxx:76
 TObjectSet.cxx:77
 TObjectSet.cxx:78
 TObjectSet.cxx:79
 TObjectSet.cxx:80
 TObjectSet.cxx:81
 TObjectSet.cxx:82
 TObjectSet.cxx:83
 TObjectSet.cxx:84
 TObjectSet.cxx:85
 TObjectSet.cxx:86
 TObjectSet.cxx:87
 TObjectSet.cxx:88
 TObjectSet.cxx:89
 TObjectSet.cxx:90
 TObjectSet.cxx:91
 TObjectSet.cxx:92
 TObjectSet.cxx:93
 TObjectSet.cxx:94
 TObjectSet.cxx:95
 TObjectSet.cxx:96
 TObjectSet.cxx:97
 TObjectSet.cxx:98
 TObjectSet.cxx:99
 TObjectSet.cxx:100
 TObjectSet.cxx:101
 TObjectSet.cxx:102
 TObjectSet.cxx:103
 TObjectSet.cxx:104
 TObjectSet.cxx:105
 TObjectSet.cxx:106
 TObjectSet.cxx:107
 TObjectSet.cxx:108