#include #include #if 1 #include "GenUtils/smart_ptr.h" #else #include #define smart_ptr boost::shared_ptr struct smart_base {}; #endif #include using namespace boost::python; /***************************************************************************** * Test classes *****************************************************************************/ class Base: public smart_base { public: virtual std::string getName() const { return "Base"; } }; class SubClass: public Base { public: virtual std::string getName() const { return "SubClass"; } }; class Interface { public: void method(smart_ptr arg) const { std::cout << "Interface::method(" << arg->getName() << ")\n"; } }; /***************************************************************************** * The extension module *****************************************************************************/ BOOST_PYTHON_MODULE(Extension) { Interface worker; smart_ptr objp = new SubClass(); worker.method(objp); class_("Interface") // methods .def("method", &Interface::method) ; class_, boost::noncopyable>("Base", no_init) .def("getName", &Base::getName) ; class_ >("SubClass") .def("getName", &SubClass::getName) ; }