Re: [ROOT] branch address problem

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jul 17 2000 - 15:56:28 MEST


Hi Damir,
The clean way to solve your problem is to have SomeClass *object a member
of a control class. Another quick way is to declare
  static SomeClass *object;

Rene Brun

Damir Buskulic wrote:
> 
> Hi,
> 
> I have a problem with branch addresses declared in a subroutine. I
> define and build a branch in a subroutine :
> 
> MainClass::function1()
> {
> ...
> object = new SomeClass();
> mObjArray->Add(object);
> tree->Branch("name","SomeClass",&object);
> ...
> }
> 
> where mObjArray is a member of my class MainClass
> I fill the tree in another subroutine. The problem is that the pointer
> to pointer &object may be lost between the two calls (the one defining
> the branch and the one filling it) because they are not in the same
> function.
> 
> For the time being, that means one has to define a global (or a member
> of MainClass), which is seen by the two functions. The problem arises if
> this member is a TObjArray or some such. I do not have access to the
> internal array of addresses fCont. This is normal in regular use, but in
> this case, it would be useful to pass it to the branch object.
> 
> Any way out of this ? I mean other than building a SomeClass** standard
> array of  pointers and managing it myself, which is not particularly
> pleasant ?
> 
> Any hints are welcome
> 
> Damir
> --
> =====================================================================
> | Damir Buskulic                  | Universite de Savoie/LAPP       |
> |                                 | Chemin de Bellevue, B.P. 110    |
> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> =====================================================================
> mailto:buskulic@lapp.in2p3.fr



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET