[C++-sig] def() vs. add_property()

Stefan Seefeld stefan.seefeld at orthosoft.ca
Wed Jul 16 16:17:30 CEST 2003


hi there,

I'v got a class that holds a reference to an external
object, which is accessible through a simple method:

class Origin {};

class Event
{
public:
   Event(const Origin *o) : my_origin(o) {}
   const Origin *GetOrigin() { return my_origin;}
private:
   const Origin *my_origin;
};

I can expose the 'Event' and 'Origin' classes, as well
as &Event::GetOrigin, to python.
However, I'd rather like to make the origin accessible
as a (read-only) property. The problem is that the
'add_property' method doesn't take a return value policy,
so I have no way of telling python how to wrap the pointer.

What is the suggested way to do that ?

Regards,
		Stefan





More information about the Cplusplus-sig mailing list