[ROOT] saving pointers

From: Clark McGrew (clark.mcgrew@sunysb.edu)
Date: Fri Dec 21 2001 - 17:51:10 MET


Merry Christmas Everyone,

I have a relatively detailed question about how pointers to objects are
saved in the output file and I tried picking apart the makecint streamer
code, but I can't exactly follow what is happening. Say I have a self
referential class hierarchy that looks something like this:

class TParent TObject {
  public:
   TDaughter *fDaughter1;
   TDaughter *fDaughter2;
};

class TDaughter : TObject {
  public:
   TParent *fParent;
   TDaughter *fSibling;
}

And it gets filled like this:

TParent p = new TParent;
TDaugher d1 = new TDaughter, d2 = new TDaughter;

// Insert the daughters with back pointers to the parent.
p->fDaughter1 = d1; d1->fParent = p;
p->fDaughter2 = d2; d2->fParent = p;

// Set the siblings for the daughters.
d1->fSibling = d2; d2->fSibling = d1;

At some point the parent class will be placed into a tree and saved to a
file.  Are all of the self referential pointers written, and then
restored when the classes is read?  Do I need to write a specialized
streamer so that only one copy of d1, and d2 are saved to the file?  

In particular, before saving "(p->d2 == p->d1->fSibling)" is true.


is 

Thanks,
Clark

-- 
Clark McGrew	                State University of New York, Stony Brook
(clark.mcgrew@sunysb.edu)	631-632-8299 (office)



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:13 MET