[再转]

     摘要: 本文讨论一种简单却有效的插件体系结构,它使用C++,动态链接库,基于面向对象编程的思想。
首先来看一下使用插件机制能给我们带来哪些方面的好处,从而在适当时候合理的选择使用。
1, 增强代码的透明度与一致性:因为插件通常会封装第三方类库或是其他人编写的代码,需要清晰地定义出接口,用清晰一致的接口来面对所有事情。你的代码也不会被转换程序或是库的特殊定制需求弄得乱七糟。
2, 改善工程的模块化:你的代码被清析地分成多个独立的模块,可以把它们安置在子工程中的文件组中。这种解耦处理使得创建出的组件更加容易重用。
3, 更短的编译时间:如果仅仅是为了解释某些类的声明,而这些类内部使用了外部库,编译器不再需要解析外部库的头文件了,因为具体实现是以私有的形式完成。
4, 更换与增加组件:假如你需要向用户发布补丁,那么更新单独的插件而不是替代每一个安装了的文件更为有效。当使用新的渲染器或是新的单元类型来扩展你的游戏时,能过向引擎提供一组插件,可以很容易的实现。
5, 在关闭源代码的工程中使用GPL代码:一般,假如你使用了GPL发布的代码,那么你也需要开放你  阅读全文

posted @ 2009-06-30 13:41 RichardHe 阅读(1420) | 评论 (0)  编辑 |

posted @ 2009-01-15 17:36 RichardHe 阅读(180) | 评论 (0)  编辑 |

posted @ 2008-11-07 10:05 RichardHe 阅读(381) | 评论 (0)  编辑 |

posted @ 2008-10-27 13:32 RichardHe 阅读(455) | 评论 (0)  编辑 |

posted @ 2008-10-20 10:37 RichardHe 阅读(2177) | 评论 (0)  编辑 |

posted @ 2008-10-20 10:09 RichardHe 阅读(966) | 评论 (0)  编辑 |

posted @ 2008-10-06 11:41 RichardHe 阅读(656) | 评论 (0)  编辑 |

posted @ 2008-09-25 09:45 RichardHe 阅读(1313) | 评论 (0)  编辑 |

posted @ 2008-09-18 17:39 RichardHe 阅读(1426) | 评论 (0)  编辑 |

posted @ 2008-09-11 19:10 RichardHe 阅读(826) | 评论 (0)  编辑 |

posted @ 2008-09-01 09:37 RichardHe 阅读(434) | 评论 (0)  编辑 |

posted @ 2008-08-30 20:16 RichardHe 阅读(543) | 评论 (0)  编辑 |

posted @ 2008-08-20 13:34 RichardHe 阅读(1332) | 评论 (-1)  编辑 |

posted @ 2008-08-05 17:51 RichardHe 阅读(1096) | 评论 (0)  编辑 |

posted @ 2008-07-29 16:09 RichardHe 阅读(6589) | 评论 (0)  编辑 |

posted @ 2008-07-29 16:08 RichardHe 阅读(276) | 评论 (0)  编辑 |

posted @ 2008-07-29 11:50 RichardHe 阅读(328) | 评论 (0)  编辑 |

posted @ 2008-07-25 16:41 RichardHe 阅读(1544) | 评论 (1)  编辑 |

posted @ 2008-07-24 20:43 RichardHe 阅读(903) | 评论 (0)  编辑 |

posted @ 2008-07-22 10:13 RichardHe 阅读(402) | 评论 (0)  编辑 |

posted @ 2008-07-22 10:10 RichardHe 阅读(137) | 评论 (0)  编辑 |

posted @ 2008-07-22 09:58 RichardHe 阅读(9521) | 评论 (0)  编辑 |

posts - 94, comments - 138, trackbacks - 0, articles - 94

Copyright © RichardHe