[ROOT] RE:Re: STL container libs (RE:accessing var

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Wed Dec 20 2000 - 14:12:45 MET


Hello George and Philippe,

Sorry for taking long for looking into this. 

I tried a couple of things about precompiled templates.
What you want is probably 90% there already. Or possibly
Philippe has done the last 10% already.

If you want to compile and link a newly instantiated 
template class while cint session, you can do following.

    // file1.C
    #pragma compile;
    #include <vector>
    #include <algorithm> // this is needed somehow..
    using namespace std;
    template class vector<float>;
    #pragma endcompile;

    root[0] .L file1.C

Cint auto compiler works and vector<float> becomes usable.
However, in this method, you can not use ROOT classes. 

So, I tried Root auto compiler.

     // file2.C
     #include <vector>
     using namespace std;
     template class vector<TObject*>;
     // #pragma link C++ class vector<TObject*>; // this does not help

     root[0] .L file2.C++

file2.C is compiled and linked without problems. However, 
vector<TObject*> appears as an entry but its' content is not.
This is because link for vector<TObject*> is not turned on
in autoLinkDef.h file.  I believe Philippe has a neat scheme 
for identifying what to expose with '#pragma link'. We only need
to add this in the autoLinkDef.h. 


Philippe,

Will you support this kind of feature in the auto compiler? Or
is the capability already there?


Thank you
Masaharu Goto



>Date: Tue, 24 Oct 2000 11:08:18 -0400
>From: "George A. Heintzelman" <gah@bnl.gov>
>To: Masaharu Goto <MXJ02154@nifty.ne.jp>, roottalk@pcroot.cern.ch
>Subject: Re: STL container libs (RE:accessing vars) 
>
>> Hello Fons,
>> 
>> There are 2 things about STL and template class precompilation.
>> 
>> 1) It looks like many people are still using ROOT without precompiled
>>   STL containers included in $CINTSYSDIR/stl/*.dll. This will make things
>>   much simpler for many users.  Are those files included and/or built in 
>>   the latest ROOT distribution?  If this is not the case, I recommend 
>>   installing pure cint also. After the installation $CINTSYSDIR/stl/*.dll
>>   are created if you use Linux, HP-UX, Solaris, VisualC++, BorlandC++,etc.
>>   If you find those, copy all of them as $ROOTSYS/cint/stl/*.dll 
>> 
>> 2) About compiling template classes with script compiler, I am still not
>>   sure about the requirement. Will you elaborate what is needed with
>>   some examples?
>
>Let's put aside the STL classes for now. I'm not sure how the 
>precompiled containers work in CINT, quite honestly. (Would you have 
>CINT-based support for things like 'vector<TLorentzVector>' available 
>if you used it? )
>
>Suppose you have a template class:
>
>template <class T> mytemplate;
>
>and you've linked this in for certain explicit instances of T, in 
>LinkDef files:
>
>#pragma link C++ class mytemplate<int>;
>#pragma link C++ class mytemplate<TObject *>;
>
>now, you're working in the interpreter, and you realize that you would 
>really like an object of (say) class mytemplate<TString>. But CINT 
>doesn't know about this, and will tell you it can't instantiate the 
>precompiled template. You don't want to jump out of CINT and recompile 
>your LinkDef file on the spot, and then restart, because you've got 
>work in your session-in-progress. What I would like is a way, to add 
>the template instantiation to CINT's vocabulary in much the same way 
>the script compiler does for an ordinary class.
>
>Now, maybe this already is possible, but I don't know how to do it. If 
>so, enlightenment would be great. What I've tried to do is stuff like 
>this:
>
>(file temp.C):
>#include "mytemplate.h"
>#include "TString.h"
>
>template class mytemplate<TString>; 
>// This is C++'s explicit instantiation syntax (see Stroustrup).
>
>and back in root do:
>
>.L temp.C+
>
>But this doesn't seem to work. Even more ideally, I would like to be 
>able to do
>.instantiate mytemplate<TString> 
>
>at the CINT command line, but this is perhaps rather harder to 
>implement (having to know the correct #include files to use).
>
>Is that clear enough?
>
>George
>
>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET