LinkDef wildcarding for class templates

Following up on my previous post (Generate LinkDef entries for class (or function) template instances) I have still not figured out how to generate Streamers for class template instances in an non-explicit manner. The reason for this is that we do not want to let every developer on the project to take care of listing the class instance in the LinkDef.

In the ROOT documentation I read the following about the LinkDef pragmas:

The [classname] and the [name] can also contain wildcards. For example:

#pragma link C++ class MyClass*;

This will request the dictionary for all the class whose name start with ‘MyClass’ and are already known to CINT (class templates need to have already been instantiated to be considered).

I do not understand what is meant by “class templates need to have already been instantiated to be considered”.

If I have MyClass<int> and MyClass<double> instantiated in my_header.h, and I feed this into rootcling to generate the dictionary. When I have in my LinkDef.h:

#pragma link C++ class MyClass<int>+;
#pragma link C++ class MyClass<double>+;

The Streamers for both are generated, but when I do:

#pragma link C++ class MyClass*+;

No Streamers are generated.

Should this work? And if so, how can I make it work?

Hi,

wildcards are supported with genreflex and selection xmls.
See genreflex --help for more information.

Cheers,
D

Thanks. When trying out with genreflex, I am faced with a possible limitation. In LinkDef it was possible to say whether or not to generate the Streamer for some classes (with a minus sign trailing the LnkDef entry). I am looking for something similar with genreflex in the selection xml file. Just excluding the class doesn’t seem to work.

Any workaround?

Hi Danilo,

I am working with Ahmad on this issue and had a look at the ROOT internals of the dictionary generation.
To me it looks that requesting no streamers is not possible with a xml selection file.
Therefore, I would propose to send a pull request.

I would add a new attribute for the class tag to be consistent with the linkdef interface <class ... modifier="+/-/!"> and add code at [1] similar to [2].

Thanks,
Lukas

[1] https://github.com/root-project/root/blob/master/core/dictgen/src/XMLReader.cxx#L927
[2] https://github.com/root-project/root/blob/master/core/dictgen/src/LinkdefReader.cxx#L387-L395

Here a link to my changes [1] (tests are still missing)
If this looks good for you, I will open a ticket, finalize my changes and send a PR.

[1] https://github.com/breitwieserCern/root/commit/3ffe99b0434a14c0ca4f6e10046ae9ce3a737c9c

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.