Hi Valentine. > My question now is how to embed this dictionary to the tree in order to allow > loading my tree and accessing my class object without loading object's > dictionary. This is possible. I will get to that below. > I would like to avoid loading my libMy.so and want to embed my dictionary > into tree itself and generate this tree with my dictionary. Per se, this is technically impossible. The "dictionary" contains more than just information on the data member of your class. It also contains information and wrappers about the member functions and the C++ class itself. The member function are not going to be available without the shared library. What is possible to store with the tree is the information on the data members and how they have been saved. This allow reading back your objects with the original shared library. However, note that if the original shared library is not available neither are the member function and the best you can do is to use a struct similar to your class. > I'm attaching my class, macros, etc. to this Email. You omitted an important piece. The file named LinkDef.h With the following LinkDef.h #ifdef __CINT__ #pragma link C++ class MyClass+; #endif With that linkdef. I am able to read your file: bash-2.05a$ ./create_tree Entering Loop ****************************************************************************** *Tree :T : An example of ROOT tree * *Entries : 1000 : Total = 28709 bytes File Size = 0 * * : : Tree compression factor = 1.00 * ****************************************************************************** *Br 0 :myclass : * *Entries : 1000 : Total Size= 28420 bytes One basket in memory * *Baskets : 0 : Basket Size= 256000 bytes Compression= 1.00 * *............................................................................* bash-2.05a$ root tree.root ******************************************* * * * W E L C O M E to R O O T * * * * Version 3.10/01 14 November 2003 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* Compiled for linux with thread support. CINT/ROOT C/C++ Interpreter version 5.15.110, Nov 9 2003 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] Attaching file tree.root... Warning in <TClass::TClass>: no dictionary for class MyClass is available root [1] T->Scan("fX") ************************ * Row * fX * ************************ * 0 * 0 * * 1 * 1 * * 2 * 2 * * 3 * 3 * * 4 * 4 * * 5 * 5 * * 6 * 6 * * 7 * 7 * * 8 * 8 * * 9 * 9 * * 10 * 10 * Cheers, Philippe. -----Original Message----- From: owner-about-root@listserv.fnal.gov [mailto:owner-about-root@listserv.fnal.gov]On Behalf Of Valentine Kouznetsov Sent: Friday, November 14, 2003 3:08 PM To: roottalk@cern.ch Cc: about-root@fnal.gov Subject: how to embed dictionary to the tree for foreign classes? Thanks to Rene's help I'm able to embed my ROOT-less class into ROOT Tree (the class without any knowledge of ROOT). But in order to read that tree and do some stuff I need to load my dictionary into root. My question now is how to embed this dictionary to the tree in order to allow loading my tree and accessing my class object without loading object's dictionary. What I found that it's possible if I add ClassDef into my class, BUT my class is ROOT-less and it will need to know where to get this definition. I don't want to include any ROOT header file into my class definition, but I would expect that can be done in the dictionary itself. I'm attaching my class, macros, etc. to this Email. Here the definitions: MyClass is ROOT-less aware class crt.C is a main program to create a root tree with this class I compile dictionary/shared library using Makefile and executable to create tree using g++ -o create_tree -I$ROOTSYS/include crt.C -L$ROOTSYS/lib -lCore -lTree -lCint -lm -lstdc++ -ldl MyClass.o mydict.o So, to be clear in order to have access to my tree with dictionary I need to load the macro gSystem->Load("libMy.so"); TFile f("tree.root"); TTree *T = (TTree*)f.Get("T"); T->Print(); and I would like to avoid loading my libMy.so and want to embed my dictionary into tree itself and generate this tree with my dictionary. Thank you, Valentine.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET