Plugin oriented App Topic is solved
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Plugin oriented App
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
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
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.
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.
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
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.TrV wrote:What is the main purpose of your future application?
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
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).
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
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Thanks Jeremie,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).
I will have a look at it
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
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
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Hello
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.
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.
Beware, there are 2 notions :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
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.
Right.evstevemd wrote:2. Plugin manager class that loads plugins and their methods
Once again, rightevstevemd wrote:3. Plugin that implements interface class
right.evstevemd wrote:4. host app
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.
wxWidgets provide a wxDynamicLibrary class which load DLL / so library, and call function of this library (getPlugin). After, this is not wxWidgets specific...evstevemd wrote:How things goes when it comes to wxWidgets?
Jérémie
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
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
[/quote]
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
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Code: Select all
typedef Plugin* ( *CreatePlugin_function)();
Code: Select all
Here how to read a function pointer definition:
typedef ReturnType (* TheFunctionPointerType)(Parameters);
Jérémie
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
And TheFunctionPointerType can be anything I like like you said in the other post, am I right?jfouche wrote:This a pointer on a function that doesn't take parameters, and returns a pointer on a Plugin class.Code: Select all
typedef Plugin* ( *CreatePlugin_function)();
Code: Select all
Here how to read a function pointer definition: typedef ReturnType (* TheFunctionPointerType)(Parameters);
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?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?