2011-02-27 73 views
5

正如我们所知,Eclipse是一个支持基于插件的应用程序开发的好框架。我正在使用C++进行编码,并想了解如何构建支持插件开发的框架。一个很好的例子是支持插件的Notepad ++。有没有我可以参考的好书或资源。C++ - 如何实现一个支持插件的框架

谢谢

+0

你可能想看看另一个SO问题及其答案:http://stackoverflow.com/questions/2627114/c -modularization框架样的OSGi – Sascha 2012-10-21 18:27:32

回答

3

我认为这是一种超杀的答案(它有很好的观点)。也许你应该先读解释器: http://www.vincehuston.org/dp/interpreter.html

然后你应该决定你的插件和脚本语言的界限,也许你应该开始阅读关于精神模块的提升。

0

可以考虑只加载共享对象(Linux)的动态,用预定义的函数钩...

#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; 
} 

上面从dlopen(3) Linux page被盗,但它示出了一个例子,其中libm.so可以是模块,和cos,可能是您的挂钩功能名称。显然这是一个完整的模块/插件框架....但它的一个开始=)