RE:

From: Marc de Kamps <dekamps_at_comp.leeds.ac.uk>
Date: Thu, 12 Jun 2008 15:48:53 +0100

Thanks,  

It now works fine with ACLIC.

I have one remaining problem. I would like to be able to write this class into a root file using a C++ program.

I use a Linkdef.h, (attached) and generate the code with: rootcint -f dict.cxx -c RootLayerDescription.h

In dict.cxx streaming code is generated which looks correct (all member variables are present in the Streamer function) and the C++ program (code below) that I use to write the object indeed writes an object to file. There is something wrong though: I can not retrieve the object and also it is not named correctly! It has as key "RootLayerDescription", but should have "goeroeboeroe".

If I carry out the corresponding code in CINT this works correctly. I can retrieve the object with ...Get("goeroeboeroe") from a file created in an earlier session.

If I use the command suggested by Axel in the mail below: rootcint -f dict.x -c RootLaterDescription.h Linkdef.h

the streamer functions again are missing the member variables. Why? Thanks,
Marc


	// write out a RootLayerDescription
	// The succes must be tested in a ROOT script

	RootLayerDescription desc;
	desc.SetName("goeroeboe");
	desc = ToRootLayerDescription(LAYER_1);

	TFile file("test/rootlayer.root","RECREATE");
	desc.Write();
	file.Close();

#-----Original Message-----
#From: owner-roottalk_at_lxbuild091.cern.ch [mailto:owner-
#roottalk_at_lxbuild091.cern.ch] On Behalf Of Rene Brun
#Sent: 12 June 2008 14:31
#To: Axel Naumann
#Cc: Marc de Kamps; roottalk_at_lxbuild091.cern.ch
#Subject: Re: [ROOT]
#
#Just an addition to Axel's mail
#You do not need to implement the Streamer function. It is generated
#automatically by rootcint
#(or ACLIC). For that the "+" in the LinkDef is the important point.
#
#Rene Brun
#
#Axel Naumann wrote:
#> Hi Marc,
#>
#> you were unlucky enough to pick a doc format that is completely
#> incompatible with ROOT's I/O. A data member commented with //! means
#> "do not stream". And putting a "+" behind the class name in the
#> LinkDef is sufficient:
#> rootcint -f dict.x -c RootLaterDescription.h Linkdef.h
#> should do.
#>
#> Cheers, Axel.
#>
#> On 2008-06-12 13:26, Marc de Kamps wrote:
#>>
#>>
#>> Hi,
#>>
#>>
#>>
#>> I have the following problem. I have an object of type
#>> RootLayerDescription. Within CINT I am able to use it. I can set
#>> values of its members and write it into a file.
#>>
#>> If I read it back from the file in a later CINT session, however, all
#>> member variables have the default values given by the constructor and
#>> not the values I wanted to save.
#>>
#>>
#>>
#>> Probably I forgot something trivial, but it would be a great help to
#>> know what it is.
#>>
#>>
#>>
#>> If I generate the dictionary file with:
#>>
#>> rootcint -f dict.x -c RootLaterDescription.h, I note that no code is
#>> generated to serialize the member variables (see code below)
#>>
#>>
#>>
#>>
#>>
#>> One final question. If I want to use the new I/O version, my
#>> understanding is that if I have a LinkDef.h file as the one attached,
#>> everything is correct. Or do I have to use
#>>
#>> rootcint -f dict.x -c RootLaterDescription.h+
#>>
#>> to generate the dictionary?
#>>
#>>
#>>
#>> Thanks,
#>>
#>> Marc
#>>
#>>
#>>
#>> void RootLayerDescription::Streamer(TBuffer &R__b)
#>>
#>> {
#>>
#>> // Stream an object of class RootLayerDescription.
#>>
#>>
#>>
#>> UInt_t R__s, R__c;
#>>
#>> if (R__b.IsReading()) {
#>>
#>> Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
#>>
#>> TNamed::Streamer(R__b);
#>>
#>> R__b.CheckByteCount(R__s, R__c, RootLayerDescription::IsA());
#>>
#>> } else {
#>>
#>> R__c = R__b.WriteVersion(RootLayerDescription::IsA(), kTRUE);
#>>
#>> TNamed::Streamer(R__b);
#>>
#>> R__b.SetByteCount(R__c, kTRUE);
#>>
#>> }
#>>
#>> }
#>>
#>>
#>>
#>>
#>>
#>>
#>>
#>> -
#>>
#>> Dr. Marc de Kamps
#>>
#>> Biosystems Group
#>>
#>> School of Computing
#>>
#>> University of Leeds
#>>
#>> LS29JT, Leeds , UK
#>>
#>>
#>>
#>> dekamps_at_comp.leeds.ac.uk <mailto:dekamps_at_comp.leeds.ac.uk>
#>>
#>> http:/www.comp.leeds.ac.uk/dekamps
#>>
#>>
#>>
#>

Received on Thu Jun 12 2008 - 16:49:44 CEST

This archive was generated by hypermail 2.2.0 : Thu Jun 12 2008 - 17:50:02 CEST