锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 视频介绍 / COM组件开发引导系列 / Conclusion结论
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

1.1.11 Conclusion结论


As you have seen, it does not really take a lot to implement and use objects based on the programming model introduced by COM. The techniques are very valuable on their own, even if you do not intend to use the COM Libraries for whatever (strange!) reason.如上所述,基于COM编程,并不需要写很多代码来使用对象。技术本事有价值,即使你不倾向于使用COM库来开发。

Taking advantage of COM allows you to: 使用COM的优点来:

  • Package your objects in a uniform way as executables or dynamic-link libraries.把你的对象以统一方式打包到DLL或可执行文件里。
  • Break your application into really reusable components, ones that you can redistribute easily to others.把你的应用拆分为实际可运行的组件,容易发布的组件
  • Be prepared to distribute your components on multiple machines, through a simple change in configuration. As COM is being ported to other platforms, you can take even take advantage of real, standardized, efficient interoperability between different platforms. 准备好向多个机器发布你的组件,通过一个配置的简单修改来实现。因为COM可部署到其它平台上,你能够采用实际的,标准化的,有效的不同平台间的互用性。

Some general tips for implementing your objects using COM: 使用COM来实现对象时可以用一些技巧,比如:

  • Before implementing a custom interface, look for interfaces that COM and/or OLE provide already. A wide variety of functionality is already covered by these interfaces. Your advantages are multiple: 在实现一个定制接口前,检查COM和/或OLE是不是已经提供了这样的接口。底层已经很现了很多接口。使用这些接口有多重好处:
    • You can take advantage of the remoting code provided for these interfaces. 可以使用这些接口的远程代码。
    • Chances are high that other standard clients—ones that you may not have thought of—will be able to use at least part of the functionality of your object, just because they know how to use a COM/OLE-provided interface.对于意想不到的接口,你有机会以标准的客户端来使用,这样可以实现你对象的部分功能。只要你知道怎样使用COM/OLE提供者接口。
    • COM provides—for free!—additional functionality related to some interfaces through standard implementations.通过标准的实现,COM提供—免费—额外的和接口相关的功能
  • When you design your interfaces, try to make them as general as possible, so that either you or others will be able to take advantage of them in the future. Publish your interfaces as widely as possible; if you can make them a standard, they will be no different from any Microsoft-provided interface, because they merge into the extensible COM architecture. 当你设计你的接口时,努力让它们具备通用性,这样你或别人会在后面利用上。尽可能公开你的接口;如果你能让它们标准化,它们就和微软提供的接口没区别了,因为他们整体融合扩展体系了里。

Making an object "COM compliant" requires a very low overhead, in terms of both implementation cost and overhead incurred.让对象“COM兼容”需要非常低的开销,在实现和执行开支上都低。

To implement a COM object, simply reuse all the "adorning" code, such as class factory objects, IUnknown implementation, Registration code (you could even make it a macro or a C++ template), and start implementing your object's functionality!为了实现COM对象,简单重用所有“修饰”代码,比如类工厂对象,IUnknown实现,注册代码(你甚至能让它们成为宏或C++模板),且开始实现你对象的功能。

Overhead in memory is very small: You basically have a 4- byte overhead per interface (the vtable pointers in the object's instance data) plus 4 bytes for the reference counter. Even the smallest object can live with this overhead (8 bytes), and you get all the advantages of making it a COM component.内存开销非常小:基本上每个接口需要额外4个字节(对象实例数据里虚函数表指针),加上引用计数的4个字节。甚至最小的对象依赖于这8个字节生存,这样你能得到COM组件的好处了。

Performance overhead in the in-process case can be beaten only by direct function calls, but the overhead is irrelevant for any real-world use. In the local case, you basically have to implement your own remoting infrastructure, either on top of RPC (like COM) or through windows messages, shared memory, and semaphores, or whatever you wish. You could probably be a little more efficient if you optimized your implementation for your kind of interface and interface usage. But usually COM's performance will be more than sufficient and will save you a lot of work!

Just spend some time thinking about which of your objects or libraries you could implement as COM objects. Which would be in-process servers, which could be local servers? How would your overall design gain, if you could use local servers?

COM can make your life a lot easier today, and prepares you for a very exciting future!

友情链接
版权所有 Copyright(c)2004-2024 锐英源软件
统一社会信用代码:91410105098562502G 豫ICP备08007559号 最佳分辨率 1440*900
地址:郑州市金水区文化路97号郑州大学北区院内南门附近