2011-02-27 66 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,可能是您的掛鉤功能名稱。顯然這是一個完整的模塊/插件框架....但它的一個開始=)