Page 1 of 5

Plugin oriented App

Posted: Mon Jun 14, 2010 5:21 am
by evstevemd
Hello friends,
please help me with this. I want to make modular application app. I need to make simple application for now as a test app that loads wxMessageBox from the plugin!

So far I need very basic things:
1. Procedures to follow (with grain of salt :))
2. Any constraint (Like ones in threading that GUI components cannot be in secondary thread).

I have read some wiki documents searching wxForum, but I miss the basics

Thanks

Posted: Mon Jun 14, 2010 6:57 am
by TrV
I have absolutely no experience in developing such kind of "pluginable" applications... but i do have some experience in developing a plugin for an application (i've developed several add-ons for TB), so i can give you some hints about the "developer-user":

I would simply say that (knowing that what is not said is what you have to code!):
- (MOST IMPORTANT) define precisely the limits of "a" plugin ("a" is whatever plugin):
. can GUI be accessed/modified?
. can logic of the base application be modified?
. ...
- (HARDEST AND LONGEST) regarding what has been set as doable/not doable, code a custom API (Application Program Interface), which means:
. architectures
. procedures
. formats
. classes
. functions
. ...

Generally all is set upon what is the main purpose of the base application, e.g.:
- foobar2000 (audio player): plugins are about GUI, sound processing and playlist management
- photoshop (image processing): plugins are about image processing
- firefox: plugins are about GUI, themes, web-surfing, favorites management, etc.
- thunderbird: plugins are about GUI, themes, mail writing, mail management, etc.

Posted: Mon Jun 14, 2010 11:38 am
by evstevemd
Thanks TrV,
your info is helpful.

EDIT:
I need to expose wxNotebook, wxMenu, wxToolBar

Posted: Mon Jun 14, 2010 3:12 pm
by TrV
What is the main purpose of your future application?

Posted: Mon Jun 14, 2010 3:28 pm
by evstevemd
TrV wrote:What is the main purpose of your future application?
One is Audio player, which I have done to some extent. I need to add any functionality without touching the Core code. The other is Bible Study tool, I need both to be modular. I also plan all other apps I will code to be in some extent plugin oriented.

The problem is, I lack basics, I hope some wxGiants in the arena to help me :)

Posted: Mon Jun 14, 2010 4:34 pm
by jfouche
A good start is to have a look to CodeLite sources, which provide a very simple and efficient way to manage plugins (codelite/Interface/plugin.h and imanager.h).
The plugin is a wxEvtHandler which receives event from the applications. The application gives access to the plugin via the IManager classes (capacity to add panels, menus, toolbars, and access to core datas).

Posted: Tue Jun 15, 2010 4:30 am
by evstevemd
jfouche wrote:A good start is to have a look to CodeLite sources, which provide a very simple and efficient way to manage plugins (codelite/Interface/plugin.h and imanager.h).
The plugin is a wxEvtHandler which receives event from the applications. The application gives access to the plugin via the IManager classes (capacity to add panels, menus, toolbars, and access to core datas).
Thanks Jeremie,
I will have a look at it 8)

Posted: Sat Jun 19, 2010 6:03 pm
by evstevemd
I thought before I invade CL sources I should familiarize myself on plugin architecture. i have read a lot of docs on net and i have come to a conclusion that I need
1. plugin interface (API is defined by this class) which is pure abstract with at least getPluginName, loadPlugin and unloadPlugin

2. Plugin manager class that loads plugins and their methods

3. Plugin that implements interface class

4. host app

am I right in this theory? How things goes when it comes to wxWidgets?
Thanks

Posted: Sun Jun 20, 2010 8:11 am
by jfouche
Hello
evstevemd wrote:I thought before I invade CL sources I should familiarize myself on plugin architecture. i have read a lot of docs on net and i have come to a conclusion that I need
1. plugin interface (API is defined by this class) which is pure abstract with at least getPluginName, loadPlugin and unloadPlugin
Beware, there are 2 notions :
1 - the plugin library interface, which is the C interface of the DLL / so library. This interface provide te capacity of retrieving the plugin class. You'll have the getPlugin function and maybe more (in CL, you have a getPluginInterfaceVersion, which allow to not load a plugin which is not whith the up to date version)
2 - the plugin interface class, which provide the functionnalities you defined : load, unload, ... It's an abstact class which need to be implemented by each plugins. This class will do the job.
evstevemd wrote:2. Plugin manager class that loads plugins and their methods
Right.
evstevemd wrote:3. Plugin that implements interface class
Once again, right
evstevemd wrote:4. host app
right.

I add once again the interface (pure abstract) class which allow to exchange information between the application and the plugins. This class must be implemented in the host app and gives acces to all information that can be shared whith the plugins (GUI to add panes, core datas, ...). In CL, tis class is the same as the one which load the plugins.
evstevemd wrote:How things goes when it comes to wxWidgets?
wxWidgets provide a wxDynamicLibrary class which load DLL / so library, and call function of this library (getPlugin). After, this is not wxWidgets specific...

Posted: Sun Jun 20, 2010 12:27 pm
by evstevemd
Thanks Jeremie,
I'm just gazing at the post saying nothing :shock:

Posted: Tue Jun 22, 2010 12:26 pm
by evstevemd
I have got UpperCase wxPlugin example and I think I will use that as learning toy :)

I have found the typedef below which I don't understand. Can anyone help me to elaborate?
Thanks

Code: Select all

class Plugin : public wxEvtHandler
{
public:
	virtual void PerformTasks()=0;
	virtual char* GetName()=0;
	virtual wxPanel* GetGUIPanel(wxWindow* parent)=0;
};
//define a function pointer type for convenience
#ifndef __PLUGIN_FUNCTION
#define __PLUGIN_FUNCTION
typedef Plugin* ( *CreatePlugin_function)();
#endif //__PLUGIN_FUNCTION

#endif
[/quote]

Posted: Tue Jun 22, 2010 1:36 pm
by jfouche

Code: Select all

typedef Plugin* ( *CreatePlugin_function)();
This a pointer on a function that doesn't take parameters, and returns a pointer on a Plugin class.

Code: Select all

Here how to read a function pointer definition:
typedef ReturnType (* TheFunctionPointerType)(Parameters);

Posted: Tue Jun 22, 2010 2:01 pm
by evstevemd
jfouche wrote:

Code: Select all

typedef Plugin* ( *CreatePlugin_function)();
This a pointer on a function that doesn't take parameters, and returns a pointer on a Plugin class.

Code: Select all

Here how to read a function pointer definition:
typedef ReturnType (* TheFunctionPointerType)(Parameters);
And TheFunctionPointerType can be anything I like like you said in the other post, am I right? :roll:

Posted: Tue Jun 22, 2010 2:50 pm
by jfouche
Right :)

Posted: Tue Jun 22, 2010 3:56 pm
by evstevemd
jfouche wrote:Right :)
Cool, let me go and try coding ;)