[C++-sig] How do I wrap virtual methods
Eric Jardim
ericjardim at gmail.com
Fri Aug 5 19:47:51 CEST 2005
2005/8/5, David Abrahams <dave at boost-consulting.com>:
>
> > So, what is the right and safe way to wrap virtual methods?
>
Everything the tutorial says, aside from the definition and use of
> default_f, seems to be right.
>
I have more doubts.
1 - using the wrapper<...> approach, the tutorial suggests me that I should
expose my class like this:
class_<BaseWrap, boost::noncopyable>("Base")
.def("f", &Base::f, &BaseWrap::default_f)
;
But what if some "Base" object where create, not by the Python code. As I
exposed "BaseWrap", "Base" was not actually exposed. Will it be a problem?
2 - How do I expose the constructors of the "Base" class on the "BaseWrap"
class? Should I define it again? Should I define the PyObject* as the first
parameter, or treat it as a normal class?
The solution I think will work:
I think that I will have to create 2 kind of objects. The normal "QObject"
wrapper, whithout the virtual functions overriden, and a "QCustomObject",
class that will never be created by C++ classes. If the user wants to
reimplement any virtual function, he should use this class.
If what I say is wrong, or a bad idea, just tell me.
[Eric Jardim]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20050805/b220628b/attachment.htm>
More information about the Cplusplus-sig
mailing list