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

Reply via email to