Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Plugin system

Name: Anonymous 2005-07-31 22:10

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: Anonymous 2005-08-03 7:29

Wouldn't you want to load X's dependencies before you load X?  Suppose you have the libraries X and Y where X depends on Y.  Realistically, we don't necessarily *know* that X's dependency on Y isn't due to some initial code that's run when X is loaded.  So, if X depends on Y, we should load Y before we load X. 

I think this is also quite relevant when you take the case of a failure to load Y into account.  We load X and drop its dependency Y into our queue of things that we still need to load.  When Y's turn comes up, though, it fails to load because Y doesn't exist.  Now we've loaded X, X depends on Y, and Y doesn't exist.  That can't be the ideal situation.

I think you'd be better off pushing X onto a stack and trying to load its dependencies first.  Basically traversing the dependency graph from the deepest points and working your way back up to the starting node

The danger of circular dependencies is that if X depends on Y and Y depends on X, you can't deterministically decide which to load first.  Your solution doesn't solve or avoid circular dependencies, it simply dictates an arbitrary order.  Granted, that's what the Windows library loading subsystem does also, and it's widely understood that circular dependencies are the fault of the library developers, but I think it's a misrepresentation to claim that dictating an arbitrary order avoids any problems with circular dependencies.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List