5

As we know, Eclipse is a good framework that supports plugins based application development. I am using c++ for coding and would like to learn how to build a framework that support the plugins development. One good example is the Notepad++ that supports plugins. Is there a good book or resource that I can refer to.

Thank you

q0987
  • 34,938
  • 69
  • 242
  • 387
  • You might want to look at another SO question and its answers: http://stackoverflow.com/questions/2627114/c-modularization-framework-like-osgi – Sascha Oct 21 '12 at 18:27

3 Answers3

4

This looks like a pretty good overview of how one could do it: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2015.pdf

Beware that this proposal is for a generic plugin framework for the C++ language. For your particular application, you may not need all the described features.

Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
3

I think that it's kind of an over kill answer (it has good points). Maybe you should first read about interpreters: http://www.vincehuston.org/dp/interpreter.html

You then should decided the boundaries of your plugins and script language, maybe you should start reading about the spirit module in boost.

ManicQin
  • 159
  • 1
  • 8
0

You can consider just loading shared objects (linux) dynamically, with predefined function hooks...

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
    void *handle;
    double (*cosine)(double);
    char *error;
    handle = dlopen ("libm.so", RTLD_LAZY);
    if (!handle) {
        fprintf (stderr, "%s\n", dlerror());
        exit(1);
    }
    dlerror();    /* Clear any existing error */
    cosine = dlsym(handle, "cos");
    if ((error = dlerror()) != NULL)  {
        fprintf (stderr, "%s\n", error);
        exit(1);
    }
    printf ("%f\n", (*cosine)(2.0));
    dlclose(handle);
    return 0;
}

The above was stolen from dlopen(3) Linux page, but it illustrates an example, where libm.so can be the module, and cos, could be the function name that your hooking to. Obviously this is far from a complete module / plugin framework.... but its a start =)

PicoCreator
  • 9,886
  • 7
  • 43
  • 64