|
Boost Users : |
From: Martin Strubel (strubi_at_[hidden])
Date: 2002-02-01 05:32:05
Hello,
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())
f_sptr->addVertex(...);
else
throw_pyException_ptrInvalid();
Does Boost support this automatically ?
Or do I have to wrap all these functions myself ?
Greetings,
- Strubi
-- Martin Strubel, Software Hooligan strubi_at_[hidden] www.blender.nl Not a Number - 3D Enabling Technology tel. +31 40 2501231 Eindhoven, The Netherlands
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net