Autoloading namespaces and template classes

I would like to exploit class autoloading (using the rootmap files) as way to avoid the frustration of many users of PyROOT (PyCintex), or ROOT I/O that the dictionary library for a given type is not loaded and in addition they do not know which library has which types. In principle the mechanism existing in ROOT works fine expect for two cases: namespaces and templates.

Look at the following example:

[code]>>> import ROOT

Traceback (most recent call last):
File “”, line 1, in ?
AttributeError: type object ‘ROOT’ has no attribute ‘Math’

import libPyROOT
<class ‘main.ROOT::Math::SVector<double,2>’>

<class ‘main.ROOT::Math::SVector<double,2>’>

In the first attempt, PyROOT does not find the namespace “Math”. ROOT namespace is OK because it is introduced already with libCore. The Math namespace is declared in CINT as type ‘a’ but there is no library associated to load it (this is normal for namespaces). Then, if I look with the complete class name with makeRootClass(), and the autoload mechanism loads the library and everything is fine again.

Similar behaviour will happen with the template ‘SVector’. It is not clear what library you need to load to obtain the right instantiation, which you do not know its name at the time you try to resolve the name ‘Svector’.

Would it be possible to tentatively return a Namespace object (if you find the name declared in CINT with type ‘a’) or a Template call object to be able to reach the next stage and have the chance to compose the complete class name to look for.

Additionaly, it would be nice to allow integers as template arguments. I had to put ‘2’ instead of 2.


are you sure that it is already declared? I don’t find the Math namespace in CINT untill loaded (note: it’s Math, not TMath, which is another namespace that is loaded a priori).

Yes, this is what is done today. E.g., access ROOT.TMath or ROOT.vector. Internally, PyROOT asks the system for the parts of a class name (b/c the lookups are getattr for each class/namespace as per python). It’s the auto-loading mechanism that doesn’t find the ROOT.Math part per se, and then PyROOT gives up. PyROOT could keep on creating partial objects on the fly, collecting the full objects, and then break up the partial objects again if the class is not found in the end, but it’s probably easier to change the autoloading to trigger on namespaces?

Will do.