免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 7626 | 回复: 22

[C++] 谁做过插件架构开发,来讲讲经验吧 [复制链接]

论坛徽章:
0
发表于 2009-06-26 14:57 |显示全部楼层
30可用积分
最近需要实现一个系统,要求能够适合不断增加的新需求,而且系统有GUI,新增功能能够在不修改主程序的情况下,方便地插入,而且主界面能够把新功能的界面整合进来,并且能够方便地与新功能交互。

哪位大哥介绍介绍经验,其它架构实现也可以,只要能够启发我的都可以说说。

最佳答案

查看完整内容

20楼什么意思?我在windows下开发,不懂so,但即便so中不能有界面代码,谁也没有强迫你把用户界面部分放到插件中,写在core中也没问题啊! 下面是用C#实现的,但用C++也没有什么太大的差别,无非是没有反射,用工厂就可以了。XML声明实际效果[ 本帖最后由 bidongliang 于 2009-6-27 09:50 编辑 ]

论坛徽章:
0
发表于 2009-06-26 14:57 |显示全部楼层
20楼什么意思?我在windows下开发,不懂so,但即便so中不能有界面代码,谁也没有强迫你把用户界面部分放到插件中,写在core中也没问题啊! 下面是用C#实现的,但用C++也没有什么太大的差别,无非是没有反射,用工厂就可以了。

XML声明

<plugin
    id="Workbench"
    name="Workbench"
    class="Workbench.WorkbenchPlugin"
    version="1.0.0">

    <assemblies>
        <assembly path="..\..\bin\Debug\Workbench.dll"/>
    </assemblies>

    <extension-point id="Workbench.Actions"/>
    <extension-point id="Workbench.KeyBinding"/>

    <extension
        point="Runtime.AutoStartCommand"
        id="Workbench.WorkbenchPlugin">        
        <command class="Workbench.WorkbenchPlugin" order="0"/>
    </extension>

    <extension point="Workbench.Actions">
        <action-set target="Workbench">
            <menu-path path="File" label="$FileLabel"/>
            <menu-path path="View" label="$ViewLabel"/>
            <menu-path
                path="File.New"
                label="$File.NewLabel"
                group="FileGroup"
                icon=".\icons\etool16\copy_edit.gif"/>
            <action
                id="Workbench.File.New.CreateNewRenderView"
                class="Workbench.CreateNewRenderView"
                group="FileGroup"
                label="$File.New.CreateNewRenderViewLabel"
                icon=".\icons\etool16\new_wiz.gif"
                tooltip="$File.New.CreateNewRenderViewTooltip"
                menu-path="File.New"
                toolbar-contributor="true"/>
            <action
                id="Workbench.File.OpenRecentFile"
                class="Workbench.OpenRecentFileCommand"
                group="FileGroup"
                style="pulldown"
                label="$File.OpenRecentFileLabel"
                icon=".\icons\obj16\activity_category.gif"
                tooltip="$File.OpenRecentFileTooltip"
                menu-path="File"
                toolbar-contributor="true"/>
            <action
                id="Workbench.File.Exit"
                class="Workbench.ExitCommand"
                group="ApplicationControlGroup"
                style="push"
                label="$File.ExitLabel"
                icon=".\icons\etool16\export_wiz.gif"
                tooltip="$File.ExitDolphinTooltip"
                menu-path="File"
                toolbar-contributor="false"
                after="*"/>
            <action
                id="Workbench.View.ShowFileExplorerPallete"
                class="Workbench.ShowFileExplorerCommand"
                group="Workbench.View.ShowPalletes"
                style="toogle"
                label="$View.ShowFileExplorerPalleteLabel"
                icon=".\icons\etool16\new_fastview.gif"
                tooltip="$View.ShowFileExplorerPalleteTooltip"
                menu-path="View"
                toolbar-contributor="true">
                <conditional failed-action="Nothing" successed-action="Check">
                    <condition pallete="Workbench.FileExplorerPalletePage" property="visible" value="true"/>
                </conditional>
            </action>
        </action-set>      
    </extension>

    <extension point="Workbench.PalletePage">
        <page id="Workbench.FileExplorerPalletePage"
            title="FileExplorer"
            class="Workbench.FileExplorerPalletePage"/>    
    </extension>

    <extension point="Workbench.KeyBinding">
        <binding key="Ctrl+E" action="Workbench.File.Exit"/>
        <binding key="Ctrl+F" action="Workbench.View.ShowFileExplorerPallete"/>
    </extension>
</plugin>


实际效果
file:///C:/Documents%20and%20Settings/ysm/%E6%A1%8C%E9%9D%A2/a.bmp
file:///C:/Documents%20and%20Settings/ysm/%E6%A1%8C%E9%9D%A2/2.bmp
file:///C:/Documents%20and%20Settings/ysm/%E6%A1%8C%E9%9D%A2/3.bmp

[ 本帖最后由 bidongliang 于 2009-6-27 09:50 编辑 ]
a.jpg
2.jpg
3.jpg

论坛徽章:
0
发表于 2009-06-26 15:07 |显示全部楼层
eclipse plug-in?

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
发表于 2009-06-26 15:10 |显示全部楼层
什么操作系统?Windows下一般用MDI,主程序加载dll插件,调用dll的接口创建MDI子窗口,dll用约定的接口与主程序交互

论坛徽章:
0
发表于 2009-06-26 15:22 |显示全部楼层
原帖由 hellioncu 于 2009-6-26 15:10 发表
什么操作系统?Windows下一般用MDI,主程序加载dll插件,调用dll的接口创建MDI子窗口,dll用约定的接口与主程序交互



linux下呢?那些vim的插件怎么做的?

论坛徽章:
0
发表于 2009-06-26 15:42 |显示全部楼层
不是传个canvas过去,就是注册个回调过来...

[ 本帖最后由 reiase 于 2009-6-26 15:47 编辑 ]

论坛徽章:
0
发表于 2009-06-26 15:47 |显示全部楼层
firefox上插件如何?

论坛徽章:
0
发表于 2009-06-26 16:09 |显示全部楼层
这样说也太笼统了吧,我也知道Eclipse & Firefox等等所用的插件架构,不过怎么实现啊。。

我在Code Porject上看了几篇文章,知道大概的实现方法,基本上是规定好App和Plugin之间互相调用的接口,Plugin按照接口要求实现

App启动时,到指定的目录下搜索所有插件,或者通过配置文件,Load所有插件,然后再根据需要调用插件实现的功能。

但是,各位大哥,概念谁都知道,来点真格儿的

比如最简单的,当我实现了一个新的功能时,主界面Load这个插件后,怎么把插件放到主界面上,然后用户就可以使用了

类似于Firefox的Google tools插件,能够嵌入到Firefox,能够互操作。

论坛徽章:
0
发表于 2009-06-26 16:23 |显示全部楼层
主程序去搜索一个目录,这个目录下面有so,so可以dlopen。够明白了吧?要不?猥琐一点?报酬不错的话,可以考虑把项目外包给我

论坛徽章:
0
发表于 2009-06-26 16:33 |显示全部楼层
firefox和eclipse的插件系统就不要考虑了吧,那个水太深

要么,传个cavas或者容器给插件,叫插件来绘图,要么注册插件的绘图函数到主程序

你要用xml定义插件的界面也行,叫主程序提插件绘图
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP