How would you write a plugin system for an image-processing application where one plugin is "dependant" on another plugin? For example I have an histogram plugin who has to call the grayscale plugin before showing the histogram. I could hard-code the grayscale function but it's ugly and I would have to do the same for a lot of other plugins.
I'm writing this in Qt (Trolltech) and C++, and I use the QLibrary object (not that it really matters...)
Name:
Anonymous2005-08-03 17:31
Now that's uncalled for. It's just a little bit of trivial recursion in the traditional manner with a "visited" bit tacked on to base-case cycles. And it allows much more flexibility in where and how the plugins can hook in to each other.
If the OP wants to sacrifice the potential generality for plugin hooks, then the other algorithm works fine. If not, a proper graph traversal with cycle detection is the way to go.
In answer to the question, maybe he would do it the "hard way" because he wants a general or extensible solution rather than a limited, quick one. I think it's pretty clear that I'm taking an approach where the desired solution should be as general as possible. Let the OP decide whether or not it fits.