[轉]COM,ATL,WTL,OLE,STL,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消息傳遞;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章