ATL Internals Working with ATL 8

, by ; ; ;
ATL Internals Working with ATL 8 by Tavares, Christopher; Fertitta, Kirk; Rector, Brent E.; Sells, Chris, 9780321159625
Note: Supplemental materials are not guaranteed with Rental or Used book purchases.
  • ISBN: 9780321159625 | 0321159624
  • Cover: Paperback
  • Copyright: 7/5/2006

  • eBook

    eTextBook from VitalSource Icon

    Available Instantly

    Online: 1825 Days

    Downloadable: Lifetime Access

    $61.86

Preface

Preface

.NET has hit the Windows programmer community like a tornado, tipping over the trailer homes of the ways that we used to do things. It's pretty much swept up the needs of most web applications and service applications, as well of most of the line-of-business applications for which we previously used Visual Basic and MFC.

However, a few stubborn hold-outs in their root cellars will give up their native code only at the end of a gun. These are the folks with years of investment in C++ code who don't trust some new-fangled compiler switches to make their native code "managed." Those folks won't ever move their code, whether there are benefits to be gained or not. This book is partially for them, if they can be talked into moving their ATL 3/Visual C++ 6 projects forward to ATL 8 and Visual Studio 2005.

Another class of developers that inhabit downtown Windows city aren't touched by tornados and barely notice them when they happen. These are the ones shipping applications that have to run fast and well on Windows 95 on up, that don't have the CPU or the memory to run a .NET application or the bandwidth to download the .NET Framework even if they wanted to. These are the ones who also have to squeeze the maximum out of server machines, to take advantage of every resource that's available. These are the ones who don't have the luxury of the CPU, memory or storage resources provided by the clear weather of modern machines needed for garbage collection, just-in-time compilation, or a giant class library filled with things they don't need. These developers value load time, execution speed, and direct access to the platform in rain, sleet, or dark of night. For them, any framework they use must have a strict policy when it comes to zero-overhead for features they don't use, maximum flexibility for customization, and hard-core performance. For these developers, there's ATL 8, the last, best native framework for the Windows platform.

For clients, ATL provides windowing, COM client smart types, extensive COM control and control hosting, MFC integration (including several MFC classes that no longer require the rest of MFC), and web service proxy generation. For servers, ATL provides full COM server and object services, and extensive support for high-throughput, high-concurrency web applications and services. For both clients and services, ATL makes aggressive use of macros and templates to give you maximum flexibility and low overhead, making sure you pay for only the features you use and giving you full transparency via the source code into how those classes map their functions to the platform. For productivity, ATL provides a full set of wizards for starting and building client and server projects.

Attributes

Pushing the productivity idea, in ATL 7 and Visual Studio 2003, the ATL team introduced attributed ATL, allowing ATL programmers to annotate their code using the same techniques that you would use to add metadata to IDL interfaces and coclasses (such as the uuid attribute). In fact, the wizards were so happy to show you this style of code that, in VS03, the Attributed option was on by default. However, all is not sunshine and bluebirds with attributes. In .NET and IDL, attributes are a real part of the programming model; support for them exists all the way down. In ATL, attributes are more of a compiler trick, like super-macros, generating base classes, macro maps, Registry scripts, and IDL files.

Unlike macros, however, ATL attributes are not transparent—you can't see what is going on very well. A compiler switch is included to show a representation of generated code, such as what base classes were added, but it has regressed in VS05. This has led to problems in understanding and debugging issues, which was not helped by bugs in the attribute-generated code. That's not to say that the rest of ATL is bug free (or that any software is bug free), but when it comes to problems in base classes or macros, ATL has always enabled you to replace problem functionality in several ways. In fact, code to work around problems was a big part of the first edition of this book because you could so easily sidestep problems.

Cues in VS05 indicate that attributes are no longer a major part of the ATL team's focus. For example, the compiler switch shows less information, not more, about what attributes generate. Most telling, however, is that the Attributed option in the VS05 wizards is no longer checked by default. 1 For that reason, although we cover the principles of ATL attributes in Appendix D, "Attributed ATL," you won't find them sprinkled throughout the book. We believe that half-hearted attributes won't make ATL 8 programmers the happiest with their native framework of choice.

Audience

This book is for the C++/COM programmer moving to ATL 8, as provided with Visual Studio 2005. ATL was built with a set of assumptions, so to be an effective ATL programmer, you need to understand not only how ATL is built, but also why. Of course, to understand the why of ATL, you must understand the environment in which ATL was developed: COM. Instead of attempting to compress all required COM knowledge into one or two chapters, this book assumes that you already know COM and spends all its time showing you the design, use, and internals of ATL. Don Box's Essential COM (Addison-Wesley Professional, 1997) is a good source of COM knowledge, if you'd like to brush up before diving into ATL.

Outline

With the exception of the first chapter, this book is arranged from the lowest levels of ATL to the highest; each chapter builds on knowledge in previous chapters. The first chapter is a brief overview of some of the more common uses for ATL and the wizards that aid in those uses. Whenever things get too detailed in the first chapter, however, we refer you to a subsequent chapter that provides more in depth coverage.

Chapters 2 through 5 present the core of ATL. Chapter 2, "Strings and Text," covers the messy world of string handling in C++, COM, and ATL. Chapter 3, "ATL Smart Types," discusses ATL smart types, such as CComPtr, CComQIPtr, CComBSTR, and CComVariant. Chapter 4, "Objects in ATL," discusses how objects are implemented in ATL and concentrates on the great range of choices you have when implementing IUnknown. Chapter 5, "COM Servers," discusses the glue code required to expose COM objects from COM servers. Chapter 6, "Interface Maps," delves into the implementation of IUnknown again, this time concentrating on how to implement QueryInterface; this chapter shows techniques such as tear-off interfaces and aggregation. Chapters 7, "Persistence in ATL"; 8, "Collections and Enumerators"; and 9, "Connection Points," discuss canned interface implementations that ATL provides to support object persistence, COM collections and enumerators, and connection points, respectively. These services can be used by components that might or might not provide a user interface. Chapters 10, "Windowing"; 11, "ActiveX Controls"; and 12, "Control Containment," concentrate on building both standalone applications and user interface components. These chapters cover the ATL window classes, controls, and control containment, respectively. Finally, Chapters 13, "Hello, ATL Server," and 14, "ATL Server Internals," cover ATL Server, which lets you build web applications on IIS. Chapter 13 introduces ISAPI and ATL Server, and C

Loading Icon

Please wait while the item is added to your bag...
Continue Shopping Button
Checkout Button
Loading Icon
Continue Shopping Button