views:

103

answers:

4

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.

A: 

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)

A.Rashad
+2  A: 

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).

Kotti
as you said, i need some cases to study, thanx for the links.
SepiDev
although python is a viable solution and is widely used as an extending language, I need to decline the dependencies of the final application,
SepiDev
+1  A: 

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.

Emmanuel Caradec
+1  A: 

An excellent Dr Dobbs serie of articles explaining how to do such a plugin framework.

my2c

neuro