Ideas for runtime loading of shared libraries.
Jacob Carlborg
doob at me.com
Thu Mar 7 10:21:10 PST 2013
On 2013-03-07 14:53, Johannes Pfau wrote:
> For OOP features it might be nice if we can iterate all classes that
> implement an Interface
>
> foreach(IWebPage page; lib)
>
> Although the question then is how to construct instances of these
> classes. Maybe the factory pattern is better for this.
Just iterate all classes, like ClassInfo.find does. Add a condition to
check if a given class implements a given interface. If the correct
class if found create it with Object.factory. Tango contains a module,
tango.core.RuntimeTraits, with a function that checks if a class
implements an interface. I'm pretty sure that Phobos has something similar.
We could create a standard plugin interface in Phobos or druntime,
something like:
interface Plugin
{
void initialize ();
void terminate ();
}
Every plugin should implement this directly or indirectly. "initialize"
would be called just after the plugin is loaded and "terminate" would be
called just before unloading.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list