Re: I/O of custom objects in CINT?

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Wed Oct 01 1997 - 19:36:27 MEST


Hi Robert,

   you've hit one of the main limitations of the CINT interpreter.
The problem is that an interpreted class can not inherit from
a compiled class (TObject is a compiled class and your TmyClass
is interpreted). We have not yet found a solution to this problem
(to fix this the interpreter should be able to patch the vtbl
so virtual functions called via TObject will be properly dispatched
to the interpreted member functions, this is highly compiler
dependent). Note: it works for non-virtual functions, but since
most functions in TObject are virtual it does generally not work.

   So a work around for the time being is to compile TmyClass together
with its dictionary in a shared library. Link the shared library
using gSystem->Load("myClass.so"). After that you can create TmyClass
objects from the interpreter and fill TTrees.

Cheers, Fons.


Robert Casties wrote:
> 
> Hello!
> 
> I've tried for some time now to create objects in CINT which can be put in
> TTrees, but it didn't work out. Is there some general limitation on doing
> that? Do strameable objects have to be compiled?
> 
> I derived my objects from TObject, used ClassDef and ClassImp macros
> (copied from Rtypes.h because of the #include problem) and Streamer
> methods created by rootcint.
> 
> If I load my files with ".L" I can use the classes and see the
> descriptions with ".class". But if I add a branch to a tree with:
>         myTree->Branch("mybranch", "TmyClass", &gMyClass, 320000, 0);
> then it is not visible (branch name is empty) with TTree::Print and
> TTree::Write causes a segfault.
> 
> The same works fine with ROOTs compiled classes.
> 
> I can give more details if needed. (System used: 1.03/03 on Linux)
> 
> Thanks
>         Robert

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET