views:

36

answers:

0

I am using SWIG to create a Python wrapper around a piece of C++ code which returns an object like this:

TH1F*GetHist();

(The class TH1F has not been written by me.) Now under Python this results in an

<Swig Object of type 'TH1F *' at 0x12da820>

My problem is that I would like to use methods of this object which SWIG does not know about. But I already have another Python wrapper around the TH1F class which also provides a copy operator. So my idea was to create a copy of the histogram and then I'd have access to all the methods. The problem is that the copy operator gives me an error:

>>> a
<Swig Object of type 'TH1F *' at 0x5948810>
>>> ROOT.TH1F(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: none of the 6 overloaded methods succeeded. Full details:
[...]
TH1F::TH1F(const TH1F& h1f) =>
  could not convert argument 1

Is there a way to circumvent this? Is the problem just the const? I hope I was able to give a concise description of the problem, if not please ask :)

Summary

I guess the question boils down to this:

(How) can I, under Python, pass a C pointer to a function that takes a const reference? Is there an easy way, or is it not possible at all?