Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plug-in architecture based c/c++ application

I need to know how to start writing an application based on plug-in architecture. I mean how to write a base code and let others develop the application by adding the plug-ins they write. I know that there is some problems in doing so in c++. most people use another language such as python to add plug-ins to their c++ application.

like image 402
sepisoad Avatar asked May 25 '10 09:05

sepisoad


3 Answers

I think, this is not the answer you expect, but you could try to examine the Rainmeter sources. It's written in C++ (some places could be done better, to my mind, but overall it's ok) and the whole application is done the way so it just handles plugins.

Even the simple API is done via plugins, there is also a bunch of examples of contributed plugins, I mean, written by someone else (I did that too, one day).

I think you could actually study a lot of new tricks in the plugin-based development by looking at other applications.

Also to mention, another good sample is Miranda IM.

Edit: Also, if I han the same task, I would actually add some python (or something like that) backend to my application and use it as the language for SDK (for example, using boost::python).

like image 159
M. Williams Avatar answered Sep 24 '22 00:09

M. Williams


You should :

  • define an interface
  • load your plugin and give it this interface

Your plugin will be able communicate with the host application through this interface. That means, you must think carefully at what you want your plugins to do.

You will probably need to support various versions of the interface if your host application changes and you add functionnalities.

like image 44
Emmanuel Caradec Avatar answered Sep 22 '22 00:09

Emmanuel Caradec


could you define access points in your application where an external application could communicate with?

let's say you define some named pipe mechanism or a TCP/IP socket, where the external application would call this API to manipulate your application?

given that you need to register these plugins in the core application before allowing them to use your application. you might even add public private certificates to authenticate the origin of this plugin, (i.e. to sign the plugin with a private key where instances of your application would validate against a public key)

like image 33
A.Rashad Avatar answered Sep 23 '22 00:09

A.Rashad