Boost logo

Boost Users :

From: Martin Strubel (strubi_at_[hidden])
Date: 2002-02-01 05:32:05


I've lately experimented with Boost.Python and found it pretty useful.
Though I've run into one thing which I couldn't figure out by
the documentation, I hope someone can give me a hint there:

I have a function returning a pointer to an 'owned' structure,
i.e. its container takes care of creation and deletion.
In Python, I want to wrap this pointer into a direct reference
to the struct, i.e. no copying. To guard the access and make sure
the object can't be accessed after the deletion, I want to wrap
the smart pointer AS a python object.

for example, a C++ function returning an 'owned' face from a mesh:

        FaceSmartPtr Mesh::addFace() { .. }

should be wrapped for access in Python like:

        f = mesh.addFace()

with subsequent calls for face manipulation like:

        f.addVertex((0.0, 0.0, 0.0))

where this should again call something like

        if (f_sptr.isValid())

Does Boost support this automatically ?
Or do I have to wrap all these functions myself ?


- Strubi

 Martin Strubel,               Software Hooligan
      Not a Number - 3D Enabling Technology
 tel. +31 40 2501231  Eindhoven, The Netherlands

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at