c++ - How do plugin systems work? -


I am working on a project where I will find the basic plugin system useful, basically, I am creating a base class and it Aadhaar class can provide a plugin to the developer. The developer then overrides it and overrides the methods. So this is where it becomes a bit unclear for me, how does it work from here? Where can the documents related to the development of such a system can be found?

Thanks

I know about all used dynamic libraries that plugin system Basically, you have to define a small, effective handshake between system kernels and plugins. Since there is no C ++ ABI, plugins should only use C API or use very compiler (and perhaps compiler version) as a system kernel.

The simplest questionable protocol will be a function, which must be provided to all the plugin developers, which gives an example of a class obtained from your base class, returns the base class as a pointer. ( extern "c" ensures that the name will not be disturbed by the function, and it is easy to search by its name.) Something like this:

  extern "C" {Plugin_base * get_plugin (); }  

Then the kernel will try to load the binary found in specified locations in the form of dynamic libraries and get_plugin () will try to find the function. If this is successful, then it calls this function and ends with a loaded plugin example.

Of course, it would be nice to work to check the version of ADI, the plugin was made versus the kernel version. (You can change that base class, after all.) And you may have other functions, which return information about the plugin (or you see it as virtual in base class). It depends very much on the nature of your system.


Comments