COM, ATL, WTL, STL, OLE, MFC


This part referenced from Microsoft

What is COM?

Microsoft COM (Component Object Model) technology in the Microsoft Windows-family of Operating Systems enables software components to communicate. COM is used by developers to create re-usable software components, link components together to build applications, and take advantage of Windows services. COM objects can be created with a variety of programming languages. Object-oriented languages, such as C++, provide programming mechanisms that simplify the implementation of COM objects. The family of COM technologies includes COM+, Distributed COM (DCOM) and ActiveX? Controls.


Microsoft provides COM interfaces for many Windows application programming interfaces such as Direct Show, Media Foundation, Packaging API, Windows Animation Manager, Windows Portable Devices, and Microsoft Active Directory (AD).


COM is used in applications such as the Microsoft Office Family of products. For example COMOLEtechnology allows Word documents to dynamically link to data in Excel spreadsheets and COM Automation allows users to build scripts in their applications to perform repetitive tasks or control one application from another.

What is COM+?
COM+ is the name of the COM-based services and technologies first released in Windows 2000. COM+ brought together the technology of COM components and the application host of Microsoft Transaction Server (MTS). COM+ automatically handles programming tasks such as resource pooling, disconnected applications, event publication and subscription and distributed transactions.
I want to build a COM or COM+ application. How do I get started?
The best resource for COM developers is the Microsoft Developer Network (MSDN). The MSDN Library contains information for developers on the Microsoft platform including a programming guide for COM development and the COM API programming reference. The Windows API is documented in Win32 and COM Development. You will also find information on COM+.
Using COM from .NET and .NET from COM
The .NET Framework provides bi-directional interoperability with COM, which enables COM-based applications to use .NET components and .NET applications to use COM components. For information on how to access .NET components from COM see http://msdn.microsoft.com/library/ms973802.aspx. To learn how to use COM components from .NET see http://msdn.microsoft.com/library/ms973800.aspx.

下面模型参考自:《COM应用程序框架》


使用MFC+ATL组合图:


使用WTL+ATL组合图

从上面两附图中很容易看出,使用MFC+ATL组合开发COM应用程序框架,MFC存在一层函数调用,代码执行速度会慢一些。小程序可能看不出来,大程序也就明显了。   如果使用WTL+ATL组合开发COM应用程序框架,就不会多一层调用,代码执行速度非常快,就像是用Win32 SDK编写代码一样没有什么区别,因为WTL是模板代码,在编译后不会存在一层函数调用。所以《COM应用程序框架》将采用WTL+ATL组合进行设计,这可能是最佳方案。

Below part referenced from wikipedia

What is the OLE?

Object Linking and Embedding (OLE) is a technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control eXtension (OCX), a way to develop and use custom user interface elements. On a technical level, an OLE object is any object that implements the IOleObject interface, possibly along with a wide range of other interfaces, depending on the object's needs.

Overview:

OLE allows an editing application to export part of a document to another editing application and then import it with additional content. For example, a desktop publishing system might send some text to a word processor or a picture to a bitmap editor using OLE. The main benefit of OLE is to add different kinds of data to a document from different applications, like a text editor and an image editor. This creates a compound document and a master file to which the document references. Changes to data in the master file immediately affects the document that references it. This is called "linking" (instead of "embedding").
Its primary use is for managing compound documents, but it is also used for transferring data between different applications using drag and drop and clipboard operations. The concept of "embedding" is central to the inclusion of multimedia in Web pages, such as video, animation (including Flash animations), and audio files within the hypertext markup language (such as HTML or XHTML) or other structural markup language used (such as XML or SGML). Modern browsers may use different embedding mechanisms than OLE.

---------------------------------

PS: 下面部分引用自百度百科:

Object Linking and Embedding,对象连接与嵌入,简称OLE技术。OLE 不仅是桌面应用程序集成,而且还定义和实现了一种允许应用程序作为软件“对象”(数据集合和操作数据的函数)彼此进行“连接”的机制,这种连接机制和协议称为组件对象模型(COM)。

OLE 是在客户应用程序间传输和共享信息的一组综合标准。允许创建带有指向应用程序的链接的混合文档以使用户修改时不必在应用程序间切换的协议。OLE基于组件对象模型(COM) 并允许开发可在多个应用程序间互操作的可重用即插即用对象。该协议已广泛用于商业上,在商业中电子表格、字处理程序、财务软件包和其他应用程序可以通过客户/服务器体系共享和链接单独的信息。
  OLE 是一种面向对象的技术,利用这种技术可开发可重复使用的软件组件(COM)。
  关于 OLE ,业界早就在抱怨它的缓慢和庞大,对市场敏感的 Microsoft 需要对那些 API 函数提出一种新的术语以适应未来的操作系统和 Internet 技术。有趣的是 Microsoft 已经宣布 OLE 不再代表对象链接与嵌入,而只是一个过去的名词而已。


This part referenced from wikipedia

What is ATL?

The Active Template Library (ATL) is a set of template-based C++ classes developed by Microsoft, intended to simplify the programming of Component Object Model (COM) objects. The COM support in Microsoft Visual C++ allows developers to create a variety of COM objects, OLE Automation servers, and ActiveX controls.[1][2] ATL includes an object wizard that sets up primary structure of the objects very quickly with a minimum of hand coding. On the COM client side ATL provides smart pointers that deal with COM reference counting.

Controls for the Internet market could have been made with the Microsoft Foundation Classes (MFC), but the market requires controls to be small and compact for downloading over the network from Web servers. MFC applications tend to be large and require support DLLs.[3] ATL allows creating smaller controls without support DLLs, so ATL is in a sense a lightweight alternative to MFC for the COM control environment.
A common use of ATL in Active Server Pages (ASP) is to construct objects that can be called from a script. While limited in certain respects, VBScript is able to call C++ Windows code contained in a COM object. In ATL version 7 (Visual Studio 2003), which directly succeeded version 3 (Visual Studio 6.0), a number of MFC classes like CString have been made available in ATL, or more precisely have been moved to an ATLMFC common layer which is shared by both libraries. ATL version 7 also introduced attributes in C++ using numerous behind the scene tricks (macros, even registry entries) in an attempt to provide something similar toCLIattributes, however these have not been particularly successful, and have been deemphasized in ATL version 8 (Visual Studio 2005); the various wizards no longer generate them by default. Version 7 also introduced new string conversion classes, which unlike their entirely-macro-based predecessors balance safety and performance: the stack allocation for the converted string is now limited to a size specified at compile-time (via a template parameter) and above that watermark heap allocation is performed.
On July 28, 2009, Microsoft released a patch to ATL to fix a bug that could allow ActiveX controls created using ATL to be vulnerable to a remote code execution security flaw.[4]

---------------------------------

其设计旨在让人们用C++方便灵活地开发COM对象。ATL本身相当小巧灵活,这是它最大的优点。用它可以创建轻量级的,自包含的,可复用的二进制代码,不用任何附加的运行时DLLs支持.


Below part referenced from wikipedia

What is the WTL?

The Windows Template Library (WTL) is a free software, object-oriented C++ template library for Win32 development. WTL was created by Microsoft employee Nenad Stefanovic for internal use and later released as an unsupported add-on to Visual Studio and the Win32 Framework SDK. It was developed primarily as a light-weight alternative to the Microsoft Foundation Classes and builds upon Microsoft's ATL, another lightweight API widely used to create COM and ActiveX libraries.

WTL provides support for implementing various user interface elements, from frame and popup windows, to MDI, standard and common controls, common dialogs, property sheets and pages, GDI objects, and other common UI elements, such as scrollable windows, splitter windows, toolbars and command bars. WTL's main objective is to deliver small and efficient code, close in size and speed to "straight" SDK programs while providing a higher-level and more flexible object model to developers. Other classes such as a string wrapper that is syntax-compatible with MFC's CString and some templated collections are also included.
Most of the WTL API is a mirror of the standard Win32 calls, so the interface tends to be familiar to most Windows programmers. Although no official documentation from Microsoft exists, the WTL Documentation Project is attempting to create a comprehensive reference for the library.[1] The WTL is not supported by Microsoft Product Support Services.

----------------------------------

WTL 架构在ATL上,对Windows 用户界面UI方面的API进行了封装,使得Windows 应用的UI开发变得十分简单、方便。
ATL 中原本就包括了一套面向Windows编程的类和类模板,其初衷是用来支持ATL 中Com 控件和OLE 属性页开发的,这也成了WTL的窗口编程的基础。 ATL 提供了基本的窗口编程功能,包括Window/Dialog 创建和管理,以及完整的消息机制。

Windows Template Library (WTL) is a C++ library for developing Windows applications and UI components. It extends ATL (Active Template Library) and provides a set of classes for controls, dialogs, frame windows, GDI objects, and more.


Below part referenced from wikipedia

What is the STL?[标准模版库]

The Standard Template Library (STL) is a C++ software library which heavily influenced many parts of the C++ Standard Library. It provides four components called algorithms, containers, functional, and iterators.[1]
The STL provides a ready-made set of common classes for C++, such as containers and associative arrays, that can be used with any built-in type and with any user-defined type that supports some elementary operations (such as copying and assignment). STL algorithms are independent of containers, which significantly reduces the complexity of the library.
The STL achieves its results through the use of templates. This approach provides compile-time polymorphism that is often more efficient than traditional run-time polymorphism. Modern C++ compilers are tuned to minimize any abstraction penalty arising from heavy use of the STL.
The STL was created as the first library of generic algorithms and data structures for C++, with four ideas in mind: generic programming, abstractness without loss of efficiency, the Von Neumann computation model,[2] and value semantics.

-----------------------------------

从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。


Below part referenced from wikipedia

What is the MFC?

The Microsoft Foundation Class Library (also Microsoft Foundation Classes or MFC) is a library that wraps portions of the Windows API in C++ classes, including functionality that enables them to use a default application framework. Classes are defined for many of the handle-managed Windows objects and also for predefined windows and common controls.

Features:
At the time of its introduction, MFC provided C++ macros for Windows message-handling (via Message Maps), exceptions, run-time type identification (RTTI), serialization and dynamic class instantiation.
The macros for message-handling aimed to reduce memory consumption by avoiding gratuitous virtual table use and also to provide a more concrete structure for various Visual C++-supplied tools to edit and manipulate code without parsing the full language. The message-handling macros replaced the virtual function mechanism provided by C++.
The macros for serialization, exceptions, and RTTI predated availability of these features in Microsoft C++ by a number of years. 32-bit versions of MFC, for Windows NT 3.1 and later Windows operating systems, used compilers that implemented the language features and updated the macros to simply wrap the language features instead of providing customized implementations, realizing upward compatibility.

----------------------------------

MFC六大关键技术:

1.MFC程序的初始化部分;

MFC有固定的类结构,根据C++的继承、多态特性把Win32对应的各部分放入MFC的封装模块中;

2.RTTI(Runtime Type Information)运行时类型识别;

通过链表实现,每个类型都保存在一个结构中[对性名称,基类、派生类],通过这些信息,保证了RTTI的实现;

3.Dynamic Creation动态创建;

4.Persistence永久保存;

5.Message Mapping消息映射;

6.Message Routing消息传递;

你可能感兴趣的:(COM, ATL, WTL, STL, OLE, MFC)