[LC++] Logical/structural question about plugin systems

David Nugent davidn at datalinktech.com.au
Tue Jun 12 00:44:55 UTC 2007

Julien Claassen wrote:
>   I'm working on an I/O library. but there's a question. I plan to have input 
> and output plugins, that can be loaded via at runtime via a user-config-file. 
> But there needs to something like an exclusion clause built into the library, 
> because some i-plugins can't work with o-plugins. How best to realise the 
> exclusion matrix? I think it might be best to do it at a global level, because 
> modules/plugins might be added and so we can easily keep track of it

In a situation like this, a little RTTI goes a long way and avoid a 
situation that could be potentially quite messy to deal with. Let the 
class hierarchy do all the work.

For example, you can derive a specific set of plugins from a common base 
class based on feature compatibility. If an input plugin requires 
certain features of the output plugin, then it could inspect the active 
output plugin to determine if it has those features (based on it being 
derived from a specific known output plugin subclass), and vice versa. 
If you have, say, class INPlug and class OUTPlug as base classes, derive 
INPlugA and INPlugB from INPlug representing different feature sets, 
then your OUTPlugs can determine if a specific descendant of INPlug is 
derived from INPlugA or is not derived from INPlugB, depending on how 
you want to set up your rules. This approach loses none of the 
flexibility you achieve by using an object oriented platform in the 
first place and avoids hard wiring or other limitations. C++ at its best.

I'm not sure how and if this would translate to your specific situation, 
but the idea may be worth exploring.


More information about the tuxCPProgramming mailing list