Just the comment to my own advice. My example may be not correct :-) ROOT can not read the class object with the "private" default ctor I am not sure about "protected" Likely one has to make it public. Valeri > -----Original Message----- > From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch] > On Behalf Of Valeri Fine > Sent: Thursday, May 22, 2003 9:26 AM > To: 'David Chamont'; roottalk@pcroot.cern.ch > Subject: RE: [ROOT] ROOT I/O and static attributes > > Hello > Generally speaking ROOT provides an "object" I/O. > > The class static attributes do belong to NO object. > > This means there is no simple and generic way to define which static > variable one wants to be saved. > I did not see any simple and elegant generic solution. > > On other hand each user can solve this problem for his/her circumstance > by introducing a singleton class to initiate and access the static > global variables properly from that class ctor. > For example you have some global variable: > (Hmm I am not sure ROOT can write ref's ? ) > > > MyGlobalVariable * MyOwnClass::gMyGlob; > > > > Define: > ------- > class globalVariableWritter : public TObject { > private: > static globalVariableWritter *fgThisPointer; > protected: > MyOwnClass &ref2 fMyGlob; > globalVariableWritter() : fMyGlob(*gMyGlob) { fgThisPointer = > this; } > public: > static globalVariableWritter *initiate() > { > if (!fgThisPointer) new globalVariableWritter(); > return fgThisPointer; > } > } > > and write it out like this: > > globalVariableWritter:: initiate()->Write() > > If ROOT doesn't support ref's then the schema above would be slightly > more complicate. > > > If you have a trouble to design such class just send me your concrete > case description then I may have provided a further assistance. > > Thank you, Valeri > > > > > > > > -----Original Message----- > > From: owner-roottalk@pcroot.cern.ch > [mailto:owner-roottalk@pcroot.cern.ch] > > On Behalf Of David Chamont > > Sent: Thursday, May 22, 2003 5:37 AM > > To: roottalk@pcroot.cern.ch > > Subject: [ROOT] ROOT I/O and static attributes > > > > > > Hi Rooters, > > > > A general question : is there any mechanism in ROOT I/O so to > > save and restore the static attributes of the classes ? > > > > I agree that the static attrbutes should be avoided, and I > > can understand you wonder why to save those attributes. > > Actually, the underlying goal is to be able to save and restore > > the state of a system of objects. > > > > Dacvid.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET