Ecere SDK/eC Forums • View topic - Dynamic loading/plugins




Ecere SDK/eC Forums

Ecere Developers Community

Dynamic loading/plugins

General help with the eC language.

Dynamic loading/plugins

Postby Heiko » Fri May 31, 2013 11:57 pm

Hi,

i am new to eC and i am trying make a application where i deliver a binary which is the application and allow the users to extend the application by making 'plugins' that are loaded dynamically on application start.

would this be possible with eC?
Heiko
 
Posts: 5
Joined: Tue Apr 16, 2013 11:40 pm

Re: Dynamic loading/plugins

Postby jerome » Sat Jun 01, 2013 12:31 pm

Hi Heiko!

Welcome to eC! This is totally possible, and made easy.

The plugins projects must be set up as dynamic library (.dll/.so/.dylib).
Say you would like to load all plugins from a folder, you can use the FileListing class to iterate through the files in a folder, and load them with eModule_Load(), e.g. if the plugin is called myplugin.dll/libmyplugin.so/libmyplugin.dylib :
Code: Select all
Module module = eModule_Load(__thisModule, "myplugin", publicAccess);


This will give you a module handle, from which you can find a class and instantiate it:
Code: Select all
Class c = eSystem_FindClass(module, "MyPluginClass");
eInstance_New(c);


A common approach would be to define a base class with virtual methods in the application, which your plugin class can derive from and override the methods it wants to implement.

Please let me know if you have more questions regarding this after you try it out. Good luck!

Best regards,

Jerome
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm


Return to eC Language

Who is online

Users browsing this forum: No registered users and 5 guests

cron