What Does This Book Cover?

 < Free Open Study > 



Over the course of this book, you will be building more and more sophisticated COM objects, as each chapter introduces you to increasingly advanced techniques. The overall organization of this text is from the bottom up. We begin with a review of the key aspects of C++ and launch into interface-based programming from a "non-COM" perspective. After this point, we spend three chapters learning to create COM servers and COM clients "in the raw" using straight C++ and the Interface Definition Language (IDL).

Once you have the necessary background, the remainder of this book focuses on how ATL can help lessen your burden as a COM developer. Rather than simply pointing out which buttons to click in the integrated CASE tools, we will move deep within the ATL framework, and examine how ATL provides support for a number of advanced COM techniques such as COM exception handling, tear-off interfaces, and aggregation, as well as a web-enabled ActiveX control.

You will also find that many COM-related concepts are first presented in straight C++ and IDL, to help you really understand what ATL is doing on your behalf. Here is a walk-through of each chapter:

Part 1: Objects and Interfaces

Microsoft's Component Object Model is a language-neutral protocol; however, it is very C++ friendly. Part 1 begins with a painless refresher on the core foundations of object-oriented programming. More importantly, this section examines interface-based programming, the foundation of all things COM.

Chapter 1: A Review of Classic Object-Oriented Programming ATL not only demands a solid understanding of COM, but of C++ as well. This chapter begins by remembering our roots, and examines why structured programming is fading (has faded?) into the background, overshadowed by the OO paradigm. The bulk of this chapter focuses on an understanding of the central pillars of C++ OOP: encapsulation, polymorphism (classical and ad hoc), and inheritance (the Is-A and Has-A relationships). We wrap up with a review of template-based programming, and see how this syntactical maneuver provides a generic form of source code reuse.

Chapter 2: Interface-Based Programming The central aspect of COM is the distinction between interface and implementation. While COM (and hence ATL) is hopelessly dependent on the interface, we can make use of the interface from a "non-COM" environment. In this chapter, you will come to see what an interface is and how to construct and implement such a creature in C++. You will see how the interface provides deeper encapsulation services, and learn how to implement interfaced-based polymorphism. As well, you will learn about the "interface contract" and how to safely extend a C++ class by versioning your interfaces.

Part 2: Core COM

ATL developers must know COM. COM developers must know C++ and IDL. Plain and simple. Part 2 walks you through the core aspects of COM from the ground up. You will have the chance to create a number of COM servers "wizard free." Here, you will build in-process and remote COM servers using nothing but C++, IDL, and a healthy dose of typing. This section breaks down into the following chapters:

Chapter 3: The Component Object Model The title says it all. Everything you know about objects and interfaces applies directly to COM development. In this chapter you will have the chance to build a COM-based DLL from the ground up, using the C++ programming language. This will expose you to IUnknown and the basic laws of COM identity, COM class factories, and component housing. As well, you will begin to learn about the system registry, the COM runtime, and the COM library. This will equip you to build C++ COM clients, which will wrap up this chapter.

Chapter 4: Type Information and Language Independence IDL is the official and correct way to describe your COM objects. One of the key reasons for doing so is to allow COM to make good on the promise of language independence. This chapter will get you up and running with the syntax of IDL, and pave the way for a number of advanced IDL constructs seen throughout the remainder of this book. Once you know how to write your interfaces, coclasses, and library statements in IDL, we wrap up this chapter by learning how to build COM clients in Visual Basic and Java (J++) which make use of the COM server you created in Chapter 3. We also examine the Visual C++ compiler extensions (smart pointers) that allow you to leverage type information when building C++ COM clients.

Chapter 5: Type Information and Location Transparency Another reason every COM project should begin with IDL is to achieve location transparency. This aspect of COM allows a COM client to access a COM server located anywhere around the world (literally) using the same block of code. This magic is provided (in part) by stubs and proxies, which are one byproduct of IDL. This chapter will dig into the architecture of DCOM, and introduce you to the inner workings of COM's marshaling layer. We will also come to understand how to configure declarative security using dcomcnfg.exe. By the end of this chapter, you will be able to remotely access the COM object you created in Chapter 3, using your language of choice. Once you have made it this far, you are completely prepared to make use of the Active Template Library.

Part 3: Core ATL

This section begins with what might be considered an ATL tutorial. Once you have become acquainted with the core CASE tools of the ATL framework, the remainder of this section examines a good deal of the raw source code while introducing you to a number of advanced COM and ATL topics.

Chapter 6: An Introduction to the Active Template Library This chapter is intended to get you up to speed with the ATL framework and the integrated CASE tools provided by ATL 3.0. We begin with the ATL COM AppWizard, and examine the details behind the choices you must make to allow this tool to assemble your component housing. You will then learn how to insert various COM objects into the AppWizard-generated server using the ATL Object Wizard. As well, you will learn about the numerous details of ATL programming such as adding/removing interfaces and coclasses, ATL debugging support, and the syntax of the registry scripting language.

Chapter 7: ATL COM Objects and COM Exceptions Once you are familiar with the ATL CASE tools, it is time to dig into the framework itself. We begin this chapter with a discussion of what multithreaded programming means to the COM developers of the world. You will come to understand the concept of an apartment as well as the various threading models provided by the Component Object Model and how ATL accounts for them. Next, we dig into the ATL source code and see how the framework provides support for core items such as IUnknown and come to understand the ATL COM map. We wrap up by learning how to throw COM exceptions in raw C++ as well as ATL and how to catch these error objects from Visual Basic and C++ clients.

Chapter 8: Object Identity and ATL COM provides a number of interesting (and somewhat strange) identity tricks. This chapter covers numerous advanced class composition techniques such as nested classes, tear-off interfaces, COM containment, and COM aggregation. You will learn how to resolve interface method name clashes in both C++ and ATL, as well as how to construct interface hierarchies. You will also come to learn a good deal more about the ATL COM map, and examine a number of additional macro entries that allow you to build sophisticated coclasses.

Chapter 9: Component Housing and ATL The innocent-looking object map structure found in every ATL project packs a wealth of information regarding your COM server. This chapter drills down into the object map and the underlying _ATL_OBJMAP_ENTRY structure. You will come to learn how ATL assembles your objects and class factories and how to override this behavior. This chapter will also illustrate how to customize the default ATL registration process, how to build COM object models, and how to assign COM categories to your coclasses.

Part 4: COM Patterns

IDispatch, IEnumXXXX, and IConnectionPoint are just some of the standard COM interfaces discussed in this section. The bulk of this section illustrates a number of "COM patterns" that enable your coclasses to function on the web and engage in bi-directional communications. As well, this section examines how one coclass can contain collections of other objects. We will be examining each of these topics in "raw C++" as well as "à la ATL."

Chapter 10: Scriptable Objects and ATL Not all COM-aware languages allow direct access to custom vTable interfaces. Some language mappings (such as VBScript) are only smart enough to communicate with COM objects supporting IDispatch. This chapter not only describes what this standard COM interface is doing under the hood, but also gives you a chance to build a number of IDispatch implementations yourself. As well, you will get to know the VARIANT data type and why we need it and how to use it. We will also learn how to construct arrays of VARIANT types (safe arrays) to help minimize round trips between the client and coclass. By the end of this chapter, you will understand how to access your ATL-savvy and raw C++ coclasses from a web-based client.

Chapter 11: COM Enumerators and COM Collections This chapter begins by examining a number of ways in which a COM object can return complex parameters to a COM client (arrays, interface pointers, structures, and so forth). With this background, the rest of the chapter discusses how a COM client can gain controlled access to sub-objects held in an object container, using COM enumerators and COM collections. You will then see how the ATL framework provides support for building each type of object container as well as examine what it would take in straight C++.

Chapter 12: Callback Interfaces and Connectable Objects COM's connectable object architecture allows clients and servers to engage in a two-way conversation. This chapter will begin by examining an ad hoc way to configure bi-directional communications using custom callback interfaces, and how VB and C++ clients may make use of it. Next, we examine the standardized architecture of "connectable objects." You will come to know the standard COM interfaces that enable this pattern (IConnectionPointContainer, IConnectionPoint, IEnumConnectionPoints, and IEnumConnections) and how ATL provides a default implementation of each.

Part 5: Windowing

Not all COM objects are invisible entities. Part 5 brings you up to snuff with ATL's support for building GUI-based coclasses. You will begin by examining how to build main windows and interactive dialogs in ATL, and wrap up by constructing an animated ActiveX control.

Chapter 13: Using ATL as a Windowing Framework Although you might not realize it, ATL does provide a set of templates to help build GUI-based Windows applications. Even though ATL does not provide all the bells and whistles of a full-blown application framework such as MFC, this chapter will show you how ATL provides just enough support to build stand-alone main windows and interactive dialog boxes. Even if you are not altogether interested in using ATL to build your next Windows application, the information presented here will provide the necessary background for the final subject of this book, ActiveX controls.

Chapter 14: Developing ActiveX Controls with ATL All of your hard work has brought you here, given that ActiveX controls require an understanding of each of the topics presented in the first 13 chapters of this book. Here you will come to understand the standard interfaces supported by an ActiveX control as well as how to build property pages for your ATL controls. Next, we will see how ATL provides framework support for your control projects, and wrap up by examining a number of advanced control topics such as "bindable" properties, property persistence, a licensed class factory, and basic Windows animation techniques.



 < Free Open Study > 



Developer's Workshop to COM and ATL 3.0
Developers Workshop to COM and ATL 3.0
ISBN: 1556227043
EAN: 2147483647
Year: 2000
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net