Re: once again about TClonesArray

From: Pasha Murat (murat@cdfsga.fnal.gov)
Date: Thu Dec 24 1998 - 01:37:53 MET


Valery Fine writes:
 > On 23 Dec 98 at 0:43, Pasha Murat wrote:
 > > 
 > > So my question is if there are serious reasons to disable the
 > > functionality of TClonesArray by 100% when a dictionary for the
 > > corresponding class is not available and the whole ROOT system is
 > > not initialized? 
 > > 
 > 
....
 >   Now look up the ctor of the class TClonesArray:
 > 
 > http://root.cern.ch/root/html/TClonesArray.html#TClonesArray:TClonesArray
 > 
 > TClonesArray(Text_t *classname, Int_t s, Bool_t) 
 > 
 >   To be able to *create* (instantiate) an object by its class name the class
 > TClonesArray should get some access to RTTI (CINT dictionary) i.e. it needs 
 > an access to the list of TClass objects mentioned above via gROOT global object.
 > 
 >   This means the ctor of TClonesArray can NOT work without dictionary at all. It
 > is not a question of "enable 80 % / disable 20 % of functionality"
 > 
 >                           "by definition"
 > 

	Hi Valery - (I'm sorry for non-finished previous mail sent to you) let 
me put it in slightly different form: suppose I comment out the part related to 
the to TROOT initialization and the check of whether a 
class has a dictionary denerated in TClonesArray constructor (see the code below).
I'd guess that it still would be possible to use such an object in many cases.
Just to give an example: TObjArray which is also supposed to keep pointers to 
TObject's doesn't check if the object put into it inherits from TObject or not.
Then one may do the checks commented out in the constructor below in the methods
where these checks are really necessary.
This would allow to decouple to a certain extent the use of TClonesArray's and 
the generation of the dictionaries which would be very nice from the point of 
view of general design.
					-Merry  Christmas, pasha

//______________________________________________________________________________
TClonesArray::TClonesArray(Text_t *classname, Int_t s, Bool_t) : TObjArray(s)
{
   // Create an array of clone objects of classname. The class must inherit from
   // TObject. If the class defines an own operator delete(), make sure that
   // it looks like this:
   //
   //    void MyClass::operator delete(void *vp)
   //    {
   //       if ((Long_t) vp != TObject::GetDtorOnly())
   //          ::operator delete(vp);       // delete space
   //       else
   //          TObject::SetDtorOnly(0);
   //    }
   //
   // The third argument is not used anymore and only there for backward
   // compatibility reasons.

//   if (!gROOT)
//      ::Fatal("TClonesArray::TClonesArray", "ROOT system not initialized");

   fKeep  = 0;
//   fClass = gROOT->GetClass(classname);
//   if (!fClass) {
//      Error("TClonesArray", "%s is not a valid class name", classname);
//      return;
//   }
//   if (!fClass->InheritsFrom(TObject::Class())) {
//      Error("TClonesArray", "%s does not inherit from TObject", classname);
//      return;
//   }
   fKeep = new TObjArray(s);
}
--------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:41 MET