Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Inter-Plugin communication

(1/3) > >>

dmoore:
As some of you know, I'm working on two plugins and plan to make one depend on the other. Obviously, the dependant plugin needs to check if the other is available before attaching itself (or at least before making calls to the first plugins API). How would I do this?

wxLearner:
Hello,
I think, LibLoader::LoadLibrary can be used to get a pointer to a wxDynamicLibrary object. If the plugin is already loaded LibLoader::LoadLibrary will return it, else it will create a new wxDynamicLibrary object and try to load the plugin. Then you can check, if the plugin was loaded by using the wxDynamicLibrary object's IsLoaded method, like PluginManager::LoadPlugin does.

LibLoader::LoadLibrary and PluginManager::LoadPlugin are defined in sdk/pluginmanager.cpp

Thank you, for making Code::Blocks even greater :D

EDIT:
Sometimes I think too complicated!
It looks like it's enough, just to use PluginManager::LoadPlugin, which returns true, if the plugin has been loaded.

dmoore:
thanks wxLearner.

byo:

--- Quote from: wxLearner on June 10, 2007, 02:26:54 pm ---Hello,
I think, LibLoader::LoadLibrary can be used to get a pointer to a wxDynamicLibrary object. If the plugin is already loaded LibLoader::LoadLibrary will return it, else it will create a new wxDynamicLibrary object and try to load the plugin. Then you can check, if the plugin was loaded by using the wxDynamicLibrary object's IsLoaded method, like PluginManager::LoadPlugin does.

LibLoader::LoadLibrary and PluginManager::LoadPlugin are defined in sdk/pluginmanager.cpp

Thank you, for making Code::Blocks even greater :D

EDIT:
Sometimes I think too complicated!
It looks like it's enough, just to use PluginManager::LoadPlugin, which returns true, if the plugin has been loaded.

--- End quote ---

You should not use LoadLibrary because it may cause some problems that C::B can't handle for now. Generally plugins must be loaded from PluginLoader and probably inside it's scanning procedures. And any other library-loading code (even when you plugin imports some symbols from other one) will fail sooner or later.

You can see how it's done inside wxSmith and wxSmithContribItems plugins. They "communicate" together - wxSmithContribItems extends functionality of wxSmith. To make it work, I had to create extra dll which is not a plugin and resides in main C::B folder. The structure is like this:


wxSmith plugin                      wxSmithContribItems plugin
            \                     /
           uses                 uses
              \                /
              wxSmith shared library (not a plugin)


Such solution (by using external library) is best I've found so far. And for some reasons it's the only acceptable when you'll want your plugin to work on MAC.

Regards
   BYO

dmoore:
thanks byo. I'll think about this approach.

now, In addition to dependencies between my own plugins I was planning to use the env vars plugin to allow the activation of environment variables for each "interpreter" action. Based on what byo is telling me this isn't possible??

Navigation

[0] Message Index

[#] Next page

Go to full version