I would like to design a plugin framework, but I have not been able to find an object oriented design that fits my objectives.
My broader design goal is for me to let users define classes in a directory. Then, the program would load the classes at run time. The classes would share a common interface such that the program could iterate over the classes, and call a method which each class would share. For instance:
Would call the .run method of all the modules loaded by the framework. The reason this approach is attractive to me is that users would be able to provide their classes with custom code, that could be run en masse at run time without having to add "include" statements and whatnot to load the class at initialization.
However, as far as I know this design does not easily meld with standard object oriented design. For instance, most languages don't expose a way to iterate over every existing subclass of a class and call a common method. I must be incorrectly conceptualizing how I would accomplish this.
The primary existing example of such a framework I know of is the metasploit framework.
What would be the correct design for such a project? I feel the main difference between this and standard plugin pattern, is that the plugins must be loaded at run time and iterated over to call a common method.