|
Boost : |
Subject: [boost] DynObj - Library for C++ runtime plugin objects
From: Arne Steinarson (asteinarson_at_[hidden])
Date: 2009-02-24 08:43:04
I'm the developer of DynObj - a C++ library for cross platform plugin
objects/components.
In short, the approach of the library is to exploit the underlying compiler
representation of virtual function tables. Since the VTable of any type
occupies a unique place in memory, the VPTR forms a valid runtime type ID.
With the help of this type ID, DynObj (in a host application) can then
access type information emitted by the plugin compiler. In effect, we get a
cross compiler variant of dynamic_cast<>:
* U* do_cast<U*>( T *pt )*
This cast operation then takes the role of *QueryInterface(...)* in COM or
xpCOM. The difference is that we're not forced into using a specific base
class for plugin capable types. We also get a meaningful type system shared
across host/plugin, not just isolated interfaces.
To go about all of this, the library relies on quite a bit of template code,
effectively tracking down object and interface offsets inside classes, and
then exporting them in a well defined, binary safe structure.
However, to simplify this (there is a bit of 'boiler plate code' needed for
each plugin type), DynObj uses a preprocessor that generates most of this,
based on a few preprocessing tags embedded in C++ comments. So it is not a
100% compile-time library.
Also when using plugins, a fair bit of template code is used, for
instantiating objects, smart pointers, executing functions on foreign
interfaces and so on. Using plugin objects becomes almost transparent in
many cases.
More information is available here: http://dynobj.sourceforge.net
Now, I wonder if there is any interest from Boost in this type of library.
At this time, I'm not eager to do a complete rewrite, since it fills our
needs pretty much as it is. If there is some interest, and the basic
approach and design is found useful to Boost, I'd be willing to take this
some steps further, time permitting. Also, general feedback and experience
with the library is appreciated.
Best Regards
Arne Steinarson, Z-Soft
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk