[C++-sig] inherit an instance, or something
Johan Rydberg
jrydberg at gnu.org
Wed Nov 8 14:18:33 CET 2006
"Roman Yakovenko" <roman.yakovenko at gmail.com> writes:
Thanks Roman!
>> class my_extended_plugin(dso_plugin):
>> def __init__(self, ...):
>> dso_plugin.__init__(self, 'libmy-plygin.so')
>>
>> Where dso_plugin.__init__ would "replace" the held pointer for 'self'
>> with the one that make_plugin('libmy-plugin.so') returns.
>> [...]
> I think you can take another approach - mix between first one and the second
> + automatic redirection:
>
> class dso_plugin(plugin):
> def __init__(self, ...):
> plugin.__init__(self)
> self.__o = make_plugin('libmy-plugin.so')
>
> def __getattr__( self, name ):
> return getattr( self.__o, name )
>
> Now you can derive your plug-ins from the dso_plugin.
>
> P.S.
> I am not sure about exact __getattr__ implementation.
But __getattr__ will only be invoked for fetching attributes from an
instance of dso_plugin, right? Will I be able to do things like
dso_plugin.set_parameter(self, ...). In other words, override a method
and invoke the default implementation.
~j
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20061108/6e682488/attachment.pgp>
More information about the Cplusplus-sig
mailing list