Here’s what I would like to do, and I’d like to know if TClassGenerator is the way to go.
I open a root file containing a TTree of some custom classes. If I did not load my custom library prior to the opening I know I will get messages like :
Warning in TClass::TClass: no dictionary for class Custom is available
But I know the relationship class name <-> library to load. Could I use a TClassGenerator to trig the loading of the library which contains Custom dictionary ?
If so, well, a code sample of TClassGenerator implementation would be greatly appreciated.
You have at least 3 choice. One it create a TClassGenerator subclass which implements GetClass pretty as
Or you can hand code a .rootmap file:
Or, probably best of all you can generate a .rootmap file using rlibmap and you linkdef files.
Thanks for the fast (!) answer.
Your solution 1 is what I would have done, but I was wondering about how to implement the other GetClass method : GetClass(const std::type_info& tif, Bool_t load). Is that one needed too ?
BTW, I’m afraid I current cannot use rlibmap, as it seems it’s a “late” addition (I use ROOT 3.05). But sounds good. Is there some doc. for it ; where is the .rootmap read in ?
rlibmap with linkdef file is new to ROOT 4.00.06.
For the other signature of TClassGenerator I recomment you just implement it as something like:
Error("GetClass with typeid. This should not have been called\n").
I.e. since you would get there if your library is not loaded, it should not be possible to pass it a typeid (which would require the library).
I guess for the time being (until we upgrade to latest and greatest ROOT), I’ll make a TClassGenerator which reads a rootmap-type file (so when we upgrade, I’ll simply remove my own class generator and let’s root do the job
Now the question is how can I specify library dependencies in my rootmap file, or may be my question is : what kind of file should I put in the -d option of rlibmap ?
Here is an extract of the system.rootmap:
Library.TProofEvent: libProof.so libTree.so libHist.so libTreePlayer.so
Library.TProofProgressDialog: libProofGui.so libProof.so libGui.so
The argument to the option -d is a list of libraries (.so) which your libraries depends on. For example:
bin/rlibmap -r etc/system.rootmap -l lib/libProofGui.so \
-d lib/libProof.so lib/libGui.so -c proof/inc/LinkDefGui.h
I’ve done a checkout of root from cvs, and can not find the system.rootmap file in the directory I got, is that normal ?
Also, under ROOT-3.05/07 (Linux RH8), I tried to make my own class generator, and it seems it’s continuously being called with classname=short, double, int etc… Is that a feature or …
The etc/system.rootmap is created when running
It is also available when important the binary files.
It is the expected behavior. Your implementation should return 0 in this cases.