Plugin oriented App Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Plugin oriented App

Post by evstevemd » Mon Jun 14, 2010 5:21 am

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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

TrV
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 630
Joined: Wed Jul 04, 2007 1:12 pm

Post by TrV » Mon Jun 14, 2010 6:57 am

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.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Mon Jun 14, 2010 11:38 am

Thanks TrV,
your info is helpful.

EDIT:
I need to expose wxNotebook, wxMenu, wxToolBar
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

TrV
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 630
Joined: Wed Jul 04, 2007 1:12 pm

Post by TrV » Mon Jun 14, 2010 3:12 pm

What is the main purpose of your future application?

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Mon Jun 14, 2010 3:28 pm

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 :)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

jfouche
Super wx Problem Solver
Super wx Problem Solver
Posts: 442
Joined: Tue May 06, 2008 4:52 pm
Location: France

Post by jfouche » Mon Jun 14, 2010 4:34 pm

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).
Jérémie

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Tue Jun 15, 2010 4:30 am

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)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Sat Jun 19, 2010 6:03 pm

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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

jfouche
Super wx Problem Solver
Super wx Problem Solver
Posts: 442
Joined: Tue May 06, 2008 4:52 pm
Location: France

Post by jfouche » Sun Jun 20, 2010 8:11 am

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...
Jérémie

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Sun Jun 20, 2010 12:27 pm

Thanks Jeremie,
I'm just gazing at the post saying nothing :shock:
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Tue Jun 22, 2010 12:26 pm

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]
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

jfouche
Super wx Problem Solver
Super wx Problem Solver
Posts: 442
Joined: Tue May 06, 2008 4:52 pm
Location: France

Post by jfouche » Tue Jun 22, 2010 1:36 pm

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);
Jérémie

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Tue Jun 22, 2010 2:01 pm

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:
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

jfouche
Super wx Problem Solver
Super wx Problem Solver
Posts: 442
Joined: Tue May 06, 2008 4:52 pm
Location: France

Post by jfouche » Tue Jun 22, 2010 2:50 pm

Right :)
Jérémie

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2263
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Tue Jun 22, 2010 3:56 pm

jfouche wrote:Right :)
Cool, let me go and try coding ;)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]

Post Reply