Code::Blocks

User forums => General (but related to Code::Blocks) => Topic started by: Anonymous on July 07, 2005, 08:16:16 pm

Title: Cross-platform Pulgin Framework
Post by: Anonymous on July 07, 2005, 08:16:16 pm
Hello.

I'm new to this board and application but i have to say i have found Code::Blocks really nice to use.

I am interested in how the cross-platform plugin framework was developed. I have had a quick look through the source code, but unfortunatly i am finding some of it difficult to understand. Could somone please provide me with a brief overview of how the plugin manager works?

Many Thanks,
Jon Cade
Title: Cross-platform Pulgin Framework
Post by: mandrav on July 07, 2005, 08:38:55 pm
Sure.

It scans the plugins dir and tries to load any dll/so (aka plugins) it finds in there.
For each one of them it hooks to the entry point, an exported function ingeniously named GetPlugin(), whose only duty is to construct and return the plugin contained in the library.
Plugins are kept in a container and participate in the event handling chain of the application.
You should take a look at pluginmanager.h and cbplugin.h (it's documented).

That's it, roughly.
If you have something more specific to ask, go ahead ;)

Yiannis.
Title: Cross-platform Pulgin Framework
Post by: per_eckerdal on July 07, 2005, 09:06:26 pm
Are you interested in creating you own cross-platform application that uses plugins?
If that is the case, you can take a look at this: http://www.shell.linux.se/edev/files/cbpluginhelp.zip (Sorry it's Dev-C++, but that was before i knew of Code::Blocks..)
It is a awfully slow and bad implementation of a plugin system, but it works :). It is designed to be cross-platform but only windows is implemented. To port it to posix, you should replace LoadLibrary with dlopen, FreeLibrary with dlclose and GetProcAddress with dlsym.

One important thing, that I have forgotten in this simple system, is that you will need to delete the plugin from the plugin dll, because the application and the plugin may use different memory allocation routines (if you compiled with another compiler, for example) otherwise you can get REALLY annoying errors.
/Per Eckerdal
Title: Cross-platform Pulgin Framework
Post by: mandrav on July 07, 2005, 09:10:01 pm
Quote from: per_eckerdal
If that is the case, you can take a look at this: http://www.shell.linux.se/edev/files/[b]cb[/b]pluginhelp.zip


Hehe, that's funny Per:
cbpluginhelp.zip ?  :lol:
(we use cb for abbreviating Code::Blocks)

Yiannis.
Title: Cross-platform Pulgin Framework
Post by: mandrav on July 07, 2005, 09:12:31 pm
@Guest: I forgot to point you to the Code::Blocks HelloWorld plugin tutorial (http://codeblocks.sourceforge.net/wiki/index.php/Creating_a_simple_%22Hello_World%22_plugin) :)

Yiannis.
Title: Cross-platform Pulgin Framework
Post by: per_eckerdal on July 07, 2005, 09:13:46 pm
That was kinda the point: Code::Blocks plugin help .zip..
:D
/Per Eckerdal
Title: Cross-platform Pulgin Framework
Post by: Anonymous on July 07, 2005, 09:26:17 pm
Thanks for the quick replys!

/Per Eckerdal: I may start a cross platform plugin bassed app, im not too sure yet. It's for my major university project so still need to think of some other ideas. One thing is for sure though, i'll use Code::Blocks as my IDE :)

I'll take a look at the linked docs, and if i have any other questions i'll be sure to stop back here.

Cheers
Jon Cade