Menu

#531 Interface plugins

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

This patch adds the ability for libstageplugin to load interfaces from plugins, similarly to the model plugin patch I submitted earlier. This patch depends on changes made in the previous patch, specifically the more generic plugin loading code. The changes have been omitted under the assumption that this patch will be applied second.

Interface plugins cannot be specified in the world file, as the player config which uses the interfaces is parsed before the world file is. So, they are specified in the config file, like this:

driver
(
name "stage"
ifplugins [
"libdio"
]
provides [
"dio:0"
]
model "mymodel"
)

Each interface plugin will have RegisterInterface called on it and must register itself as an interface at that point, like this:

extern "C"
{
void RegisterInterface(void)
{
RegisterInterface( PLAYER_DIO_CODE, InterfaceCreator<InterfaceDio> );
}
}

I did run into a problem where an interface plugin depends on a model plugin but cannot resolve the symbols because the interface plugin was loaded first. My solution was simply to put both plugins in the same shared library and let it be loaded twice (libtool ensures it is not actually loaded twice). It's not elegant but I'm not sure what else to do.

Discussion

  • RAZOR

    RAZOR - 2010-01-05

    Patch to add support for plugin interfaces

     
  • Richard Vaughan

    Richard Vaughan - 2010-01-06

    another great idea, thanks.

    I'll think a bit about the name resolution problem. Can probably get around it by making the registration a two-step process.

    - rtv

     
  • RAZOR

    RAZOR - 2010-01-06

    Thanks. I did forget to mention one thing. To make it easy to compile interface plugins, I changed the CMakeLists to install p_driver.h. However, p_driver depends on stage.hh, and expects it to be in subdirectory libstage. I did not want to change the directory stage.hh is installed into, as that would break other peoples code. So, I simply installed stage.hh in both places. Perhaps you can come up with a better solution?

     

Log in to post a comment.