#530 Plugin models

open
Stage (103)
5
2012-12-16
2010-01-04
RAZOR
No

I've written some code to allow new model types to be registered by specifying a plugin library in the world file, with syntax:

plugin "libmymodel"

Upon parsing the plugin statement the function RegisterPlugin will be called, so the plugin library must contain code something like:

extern "C"
{
void RegisterPlugin(void)
{
Register( "mymodel", Creator<ModelMyModel> ); // Register model with stage so it can be created
}
}

The idea is that you should not have to reinstall stage every time you modify a model, you should be able to use a standard stage package and still develop your own models. I should have a similar plugin system ready for interfaces in libstageplugin soon.

To avoid duplicate code, I have shifted the plugin loading code out of LoadControllerModule and into stage.cc so I can reuse it for other plugin systems. I'm not sure if that is the best place to put it, and I hope I have not made any mistakes while making it more generic.

Discussion

  • RAZOR

    RAZOR - 2010-01-04

    Patch to add support for plugin models

     
  • Richard Vaughan

    Richard Vaughan - 2010-01-06

    this is a great idea, thanks very much for the patch. I will test it out with a view to inclusion in the next release.
    - rtv

     
  • RAZOR

    RAZOR - 2010-01-07

    I just realized that models often need worldfile.hh and option.hh, so it would be nice if these were installed with stage.hh.

     

Log in to post a comment.