Reflection when using boost

Hi,
I am trying to write a simple TreeWriter class that has reflection built in so I can use it in python and C++. It seems that everything compiles well however I cannot get my code to run in the pyROOT environment. I attach the code in a simple example in test.tar.gz the error I am getting is as follows

  Traceback (most recent call last):
  File "./TreeWriter.py", line 8, in <module>
    tw.column( "test", int(0) )
TypeError: void TreeWriter::column(const string& variable, const boost::any& value) =>
    could not convert argument 2
I have 4 files in the upload Dict.h,  Dict.xml,  TreeWriter.cpp,  TreeWriter.hpp  and TreeWriter.py. Dict.h is simply the header files to be compiled and passed to genreflex, Dict.xml is the lcgdict definitions, TreeWriter.{hpp,cpp} are the source code and finally TreeWriter.py is the loading of the created dictionary.

I am doing the following to create the libs:-

g++ -fPIC -shared -c -W -Wall TreeWriter.cpp -o TreeWriter.so `root-config --cflags` 
genreflex Dict.h --deep --rootmap=libCharmlessSelection.rootmap --rootmap-lib=libCharmlessSelection.so --select=Dict.xml -I/usr/local/root/include/root
g++ -O2 -fPIC -shared Dict.h Dict_rflx.cpp TreeWriter.so -o libCharmlessSelection.so  `root-config --cflags --glibs` -lReflex -lCintex -lEG -lGui -lHist -lTMVA -lTreePlayer -lGenVector -lRooFitCore -lRooFit -lRooStats 

Then to reproduce the error I run

./TreeWriter.py 
Traceback (most recent call last):
  File "./TreeWriter.py", line 8, in <module>
    tw.column( "test", int(0) )
TypeError: void TreeWriter::column(const string& variable, const boost::any& value) =>
    could not convert argument 2
TFile**		output.root	
 TFile*		output.root	
  OBJ: TTree	data	data : 0 at: 0x2be9730

I tried hiding the boost things from CINT but that clearly will not help since it still doesn’t know how to use them. Thanks for any help you can provide.

Cheers
Matt
test.tar.gz (2.84 KB)

Matt,

automatic conversion using temporaries is not supported by PyROOT (this is both because it’s hard to do as well as easy to work around by providing an explicit conversion, and hence a long-standing, low priority TODO item). But even if it were supported, it would still require a dictionary and hence CINT should know about the class. By hiding boost::any from CINT, it won’t work.

Since you are using genreflex rather than rootcint, however, you can see whether boost::any (with an explicit instantiation of the templated constructor for all the types to be used) can be bound. Then use that for explicit conversion.

Cheers,
Wim