See OBT::Plugin and OBT::PluginInformation. This is the old version of plug-in. See Plug-in object library for the new one.
See OBT::PluginInterface and OBT::PluginLoader.
... #include "OBTPluginInterface.h" ... class MY_EXPORT_API MyPlugin : public OBT::PluginInterface { protected : MyPlugin() ; public: virtual const OBT::PluginInformation& getInformation() const { return _info ; } void aMethod() ; protected: // Minimal method virtual bool init( const std::string& ) { return true ; } // Minimal method virtual bool finish() { return true ; } protected : virtual ~MyPlugin() {} OBT::PluginInformation _info ; } ; ...
...
MyPlugin::MyPlugin()
: _info( ... my plug-in informations ... )
{
}
void MyPlugin::aMethod()
{
...
}
... OBT_EXPORT_PLUGIN_API( MyPlugin ) ; ...
extern "C" { OBT_EXPORT_API_DECL PluginInterface* get_OBT_PluginInterface() { ... } }
... OBT::PluginInterface* plugin = OBT::PluginLoader::getInstance().load( path, "myPlugin" ) ; if( 0 != plugin ) { const OBT::PluginInformation& info = plugin->getInformation() ; ...
... MyPlugin* plugin = OBT::PluginLoader::getInstance().loadT< MyPlugin >( path, "myPlugin" ) ; if( 0 != plugin ) { plugin->aMethod() ; ...
... MyPlugin* plugin = ... ... OBT::PluginLoader::getInstance().unload( plugin ) ; ...
... OBT::PluginInterface* plugin = OBT::PluginLoader::getInstance().load( path, "myPlugin" ) ; OBT::OldPlugin* oldPlugin = dynamic_cast< OBT::OldPlugin* >( plugin ) ; MyPlugin* newPlugin = dynamic_cast< MyPlugin* >( plugin ) ; if( 0 != oldPlugin ) { // this is an old plugin const OBT::PluginInformation& info = plugin->getInformation() ; ... } if( 0 != newPlugin ) { // this is an new plugin plugin->aMethod() ; ... } else { // Bad type delete plugin ; }