Plugin oriented App Topic is solved
- xaviou
- Super wx Problem Solver
- Posts: 437
- Joined: Mon Aug 21, 2006 3:18 pm
- Location: Annecy - France
- Contact:
Hi to all !
I am actually working on such an application.
This application is a "ToDo list manager"
It consists of a basic application that manages tasks, sub-tasks, sub-sub-tasks, and so on.
It can be extended with plugins of 3 types:
- datas plugins, that extends tasks properties
- import/export plugins that allows, as their name suggests it, to import or export datas from/to other application like this
- tools plugins, that offers other capabilities to the application (for example, reports creation, auto-update).
The architecture is the following :
- The main app that creates the interface, and shows basics tasks properties
- A "hard linked" dynamic library that contains managers (PluginsManager, SettingsManager, DatasManager, and some usefull functions/classes that can be used by the app or the plugins)
- Differents plugins that are dynamically detected and loaded at runtime
The PluginsManager is the "core class" of the system : it keeps an "ArrayOfPlugins" that are loaded, so it can ask them to do something when needed.
In other cases, Plugins can acces the PluginsManager global object, and use it to send custom events to the app.
I don't know if it is the best way to do a plugins system, but it works perfectly.
If you need more infos on it, do not hesitate to ask for.
Regards
Xav'
I am actually working on such an application.
This application is a "ToDo list manager"
It consists of a basic application that manages tasks, sub-tasks, sub-sub-tasks, and so on.
It can be extended with plugins of 3 types:
- datas plugins, that extends tasks properties
- import/export plugins that allows, as their name suggests it, to import or export datas from/to other application like this
- tools plugins, that offers other capabilities to the application (for example, reports creation, auto-update).
The architecture is the following :
- The main app that creates the interface, and shows basics tasks properties
- A "hard linked" dynamic library that contains managers (PluginsManager, SettingsManager, DatasManager, and some usefull functions/classes that can be used by the app or the plugins)
- Differents plugins that are dynamically detected and loaded at runtime
The PluginsManager is the "core class" of the system : it keeps an "ArrayOfPlugins" that are loaded, so it can ask them to do something when needed.
In other cases, Plugins can acces the PluginsManager global object, and use it to send custom events to the app.
I don't know if it is the best way to do a plugins system, but it works perfectly.
If you need more infos on it, do not hesitate to ask for.
Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
I think I will need help on that, but I think one Plugin Manager is enough!xaviou wrote:Hi to all !
I am actually working on such an application.
This application is a "ToDo list manager"
It consists of a basic application that manages tasks, sub-tasks, sub-sub-tasks, and so on.
It can be extended with plugins of 3 types:
- datas plugins, that extends tasks properties
- import/export plugins that allows, as their name suggests it, to import or export datas from/to other application like this
- tools plugins, that offers other capabilities to the application (for example, reports creation, auto-update).
The architecture is the following :
- The main app that creates the interface, and shows basics tasks properties
- A "hard linked" dynamic library that contains managers (PluginsManager, SettingsManager, DatasManager, and some usefull functions/classes that can be used by the app or the plugins)
- Differents plugins that are dynamically detected and loaded at runtime
The PluginsManager is the "core class" of the system : it keeps an "ArrayOfPlugins" that are loaded, so it can ask them to do something when needed.
In other cases, Plugins can acces the PluginsManager global object, and use it to send custom events to the app.
I don't know if it is the best way to do a plugins system, but it works perfectly.
If you need more infos on it, do not hesitate to ask for.
Regards
Xav'
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 solution :
1 - A PluginEvtHandler where you post all yours messages
2 - All plugin subscribe to the plugins events with the PluginEvtHandler class.
To send an event :
If you want I can provide you a full sample (in a few days, i'm a little bit busy today).
1 - A PluginEvtHandler where you post all yours messages
2 - All plugin subscribe to the plugins events with the PluginEvtHandler class.
Code: Select all
// This sould be a singleton class, to be sure it's unique
class PluginEvtHandler : public wxEvtHandler
{
};
class IPlugin : wxEvtHandler
{
public:
IPlugin(PluginEvtHandler* handler)
{
handler->Connect(My_Evt, ...);
}
};
Code: Select all
// thePluginEvtHandler is the only instance of PluginEvtHandler
thePluginEvtHandler->AddPendingEvent( event );
Jérémie
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Thanks and I will appreciate that sample any timejfouche wrote:A solution :
1 - A PluginEvtHandler where you post all yours messages
2 - All plugin subscribe to the plugins events with the PluginEvtHandler class.
To send an event :Code: Select all
// This sould be a singleton class, to be sure it's unique class PluginEvtHandler : public wxEvtHandler { }; class IPlugin : wxEvtHandler { public: IPlugin(PluginEvtHandler* handler) { handler->Connect(My_Evt, ...); } };
If you want I can provide you a full sample (in a few days, i'm a little bit busy today).Code: Select all
// thePluginEvtHandler is the only instance of PluginEvtHandler thePluginEvtHandler->AddPendingEvent( event );
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 have wrote simple buggy plugin in C++ (no wxWidgets for now) to test my understanding of the concept. Please download run and tell me where a I should correct what
It is just to get the concept sunk into my head and it have CodeLite project.
After I pass this one I will go back to wxThing
Thanks
It is just to get the concept sunk into my head and it have CodeLite project.
After I pass this one I will go back to wxThing
Thanks
- Attachments
-
- PluginX.zip
- (448.89 KiB) Downloaded 190 times
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
Now that I have grasped the concept somehow, I'm swinging to wxWidgets. In my DemoApp I want to expose minimal app, that is wxMenus, wxNotebook, and status bar.
So How do I make abstract class? Should I make multiple inheritance like one below? If no which approach do you suggest? If yes what are pros and cons?
Thanks,
Here is what I think of IPlugin.h
So How do I make abstract class? Should I make multiple inheritance like one below? If no which approach do you suggest? If yes what are pros and cons?
Thanks,
Here is what I think of IPlugin.h
Code: Select all
#include <wx/wx.h>
#include <wx/aui/auibook.h>
class IPlugin: public wxMenu, wxAuiNotebook, wxStatusBarGeneric{
public:
virtual void addPluginMenuItem(wxMenu* menu) = 0;
virtual void addMenuwxMenu* menu) = 0;
virtual wxString getStatusBarText()=0;
virtual wxString supportedHostVersion()=0;
};
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?
- xaviou
- Super wx Problem Solver
- Posts: 437
- Joined: Mon Aug 21, 2006 3:18 pm
- Location: Annecy - France
- Contact:
Hi
I think you should only derive you plugins from wxEvtHandler :
Here is what I've done to create the base class of plugins that can have differents types :
Then, for each plugin type, I have something like that :
The first type of plugins have to create a wxPanel to extent the main interface :
And, for example, the "Tool" plugin type, that only have a function to be executed from a menu :
Hope it will help you understand the concept...
Regards
Xav'
I agree with that...jfouche wrote:OUps, that's not the good way.
I think you should only derive you plugins from wxEvtHandler :
Here is what I've done to create the base class of plugins that can have differents types :
Code: Select all
#include <wx/wx.h>
enum Pugin_Type
{
PT_UNKNOWN=0,
PT_DATAS,
PT_IMPEXP,
PT_TOOL
};
class PluginBase : public wxEvtHandler
{
public:
PluginBase(Pugin_Type type) { m_Type=type; }
Pugin_Type GetPluginType() { return m_Type; }
virtual wxString GetPluginName()=0;
private:
Pugin_Type m_Type;
};
The first type of plugins have to create a wxPanel to extent the main interface :
Code: Select all
class DataPlugin : public PluginBase
{
public:
DataPlugin() : PluginBase(PT_DATAS) { }
virtual wxPanel* CreatePluginPanel(wxWindow* parent)=0;
//...
};
Code: Select all
class ToolPlugin : public PluginBase
{
public:
ToolPlugin() : PluginBase(PT_TOOL) { }
virtual bool ExecuteTool(wxXmlNode* datas)=0;
};
Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
thanks Xav,xaviou wrote:Hi
I agree with that...jfouche wrote:OUps, that's not the good way.
I think you should only derive you plugins from wxEvtHandler :
Here is what I've done to create the base class of plugins that can have differents types :Then, for each plugin type, I have something like that :Code: Select all
#include <wx/wx.h> enum Pugin_Type { PT_UNKNOWN=0, PT_DATAS, PT_IMPEXP, PT_TOOL }; class PluginBase : public wxEvtHandler { public: PluginBase(Pugin_Type type) { m_Type=type; } Pugin_Type GetPluginType() { return m_Type; } virtual wxString GetPluginName()=0; private: Pugin_Type m_Type; };
The first type of plugins have to create a wxPanel to extent the main interface :And, for example, the "Tool" plugin type, that only have a function to be executed from a menu :Code: Select all
class DataPlugin : public PluginBase { public: DataPlugin() : PluginBase(PT_DATAS) { } virtual wxPanel* CreatePluginPanel(wxWindow* parent)=0; //... };
Hope it will help you understand the concept...Code: Select all
class ToolPlugin : public PluginBase { public: ToolPlugin() : PluginBase(PT_TOOL) { } virtual bool ExecuteTool(wxXmlNode* datas)=0; };
Regards
Xav'
my head is tired now after some time of reading and working. I will read it tomorrow
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
Code: Select all
#include <wx/wx.h>
enum Pugin_Type
{
PT_UNKNOWN=0,
PT_DATAS,
PT_IMPEXP,
PT_TOOL
};
class PluginBase : public wxEvtHandler
{
public:
PluginBase(Pugin_Type type) { m_Type=type; }
Pugin_Type GetPluginType() { return m_Type; }
virtual wxString GetPluginName()=0;
private:
Pugin_Type m_Type;
};
The first type of plugins have to create a wxPanel to extent the main interface :
Code: Select all
class DataPlugin : public PluginBase
{
public:
DataPlugin() : PluginBase(PT_DATAS) { }
virtual wxPanel* CreatePluginPanel(wxAUINotebook* parent)=0;
};
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?
- xaviou
- Super wx Problem Solver
- Posts: 437
- Joined: Mon Aug 21, 2006 3:18 pm
- Location: Annecy - France
- Contact:
You can absolutely do "normal" event binding, even by a classic event table, or dynamically (my prefered) with the "Connect" methodevstevemd wrote:so there I have My Notebook plugin, but then I have a question. How can I bind events to my panel before I attach it to AUINotebook? Do i do normal event binding or because it is a plugin there is special way?
And events can also be catched by the main application.
For example :
- you create a button on your panel, and you give this button the id "wxID_EXIT"
- your main application has an entry menu with the same id, connected to a method witch allow closing the frame
- if the clic on the button isn't connected to a plugin's method, it will be catched by the frame's one (and I think it will be catched by the frame before it should be catched by the plugin).
Hope I am clear enough : if not, don't hesitate to ask for more details.
Regards
Xav'
My wxWidgets stuff web page : X@v's wxStuff
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
I hope now I'm about to make it. And I thanks you guys who are boosting me a lot
However I have another Question on How do I code the Manager and Load the Plugins. I have been thinking and I feel as if I hit a wall, nothing just moves. Would you guys shed light on that?
Thanks!
However I have another Question on How do I code the Manager and Load the Plugins. I have been thinking and I feel as if I hit a wall, nothing just moves. Would you guys shed light on that?
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?