Adding a class

From: Marc de Kamps <dekamps_at_comp.leeds.ac.uk>
Date: Mon, 19 Nov 2007 10:41:05 -0000


Hi,

I'm using rootcint for the first time. It doesn't quite behave as expected and I'm probably overlooking something simple.

Attached is a simple class. I'm running root 5.17/04 under Linux. I have generated dictionary files as follows.
I run rootcint as follows:
rootcint blaclassdict.cxx -c BlaClass.h

The dictionary files are generated. I then run root as follows:

root [0] .L /home/csunix/dekamps/tmp/BlaClass.cpp
root [1] BlaClass* p = new BlaClass;
root [2] p->AddOne();
root [3] p->AddOne();
root [4] cout << p->Size() << endl;

2
root [5] TFile* p_file = new TFile("bla.root","RECREATE");
root [6] p->Write();
root [7] p_file->Close();
root [8]

So, far behaviour is expected. When I try to open the file I have just created, the object is of TObject type and not of BlaClass type, which causes problems when trying to read it back in:
root [0] .L /home/csunix/dekamps/tmp/BlaClass.cpp
root [1] TFile* p_file = new TFile("bla.root");
root [2] p_file->ls();
TFile**         bla.root
 TFile*         bla.root
  KEY: TObject  TObject;1       Basic ROOT object
root [3] BlaClass* p_bla = (BlaClass*)p_file->Get("TObject"); root [4] cout << p_bla->Size() << endl;
201

This looks like slicing and I have probably forgotten something simple. Is this usage of rootcint correct in principle? What goes wrong here?

Input appreciated

Marc

-
Dr. Marc de Kamps
Biosystems Group
School of Computing
University of Leeds
LS29JT, Leeds, UK

dekamps_at_comp.leeds.ac.uk
http:/www.comp.leeds.ac.uk/dekamps

Received on Mon Nov 19 2007 - 11:41:27 CET

This archive was generated by hypermail 2.2.0 : Mon Nov 19 2007 - 17:50:01 CET