Active Template Library

Slides:



Advertisements
Similar presentations
Component Object Model
Advertisements

COM vs. CORBA.
Traps and pitfalls for VC6, ATL, C++ May be obvious ? May be not ? Mark Bartosik.
Why COM and.Net? Jim Fawcett CSE775 – Distributed Objects Spring 2005.
Image Management System Supervisor Dmitry Davidov Students Tanya Kostanovich Roma Kagan.
COM: Microsoft's Component Object Model Andrew C. Hopkins CSCI 397C-16 Object Oriented Database Design and Management Professor Renee Renner.
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
1 Modular Software/ Component Software 2 Modular Software Code developed in modules. Modules can then be linked together to produce finished product/program.
Visual Basic: An Object Oriented Approach 12 – Creating and using ActiveX objects.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Obsydian OLE Automation Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
COM vs. CORBA Computer Science at Azusa Pacific University September 19, 2015 Azusa Pacific University, Azusa, CA 91702, Tel: (800) Department.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
COM/DCOM Implementation Basics of: Object creation and access Object Reuse Interface referencing.
OLE / COM Helia / Martti Laiho Sources: MSDN Kraig Brockschmidt: Inside OLE Orfali-Harkey-Erwards: Client/Server Survival Guide.
COMCOM omponent bject odel After this presentation, you will: Be Able To: Conceptual understanding of COM How it works, What it’s used for Decode Acronyms.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
A COM implementation of the KSpace A ‘Knowledge Space prototype’ by Santhosh CST
OOMI From COM to DCOM.
Ni.com Understanding COM/ActiveX Jeff Paulter Staff Software Engineer Thurs Aug 17 10:15-11:30 a.m., 1:45-3:00 p.m. Ash (10A) Jeff Paulter Staff Software.
Making LabVIEW look like an IOC Kay-Uwe Kasemir, LANL May 2002.
Introduction to COM and ActiveX Controls. What is an object? In the Fayad sense of the word.
Seminarium on Component-based Software Engineering Feraaz Imami LIACS – Leiden University Fall 2005 Component Object Model (COM)
DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation.
1 Developing for Test Automation and Accessibility Using Programmatic Access to the UI Thomas Logan FUN307 Program Manager Microsoft Corporation.
Jim Fawcett CSE687 – Object Oriented Design Spring 2001
Packaging and Deploying Windows Applications
Jim Fawcett CSE775 - Distributed Objects Spring 2014
Component Object Model(COM)
Windows Programming Environments
Copyright © Jim Fawcett Spring 2017
CSE791 - Distributed Objects, Spring 2002
Component Object Model
Component Object Model
Jim Fawcett CSE775 – Distributed Objects Spring 2017
Abstract Factory Pattern
CSE775 - Distributed Objects, Spring 2006
Jim Fawcett CSE687 – Object Oriented Design Spring 2016
Jim Fawcett CSE775 – Distributed Objects Spring 2004
Putting the Distributed into COM
Jim Fawcett CSE775 – Distributed Objects Spring 2009
Jim Fawcett CSE775 - Distributed Objects Spring 2016
Jim Fawcett CSE687 – Object Oriented Design Spring 2002
ActiveX Control Recipe
Jim Fawcett CSE791 – Distributed Objects Spring 2001
Native / Managed Interop
CSE687 - Object Oriented Design class notes Survey of the C++ Programming Language Jim Fawcett Spring 2004.
Out-of-Process Components
C# COM Interoperability Late Binding
Jim Fawcett CSE775 – Distributed Objects Spring 2007
Jim Fawcett CSE775 – Distributed Objects Spring 2012
Jim Fawcett CSE775 – Distributed Objects Spring 2003
Jim Fawcett CSE687 – Object Oriented Design Spring 2016
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Jim Fawcett CSE687 – Object Oriented Design Spring 2009
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
Chapter 10 Thinking in Objects
Jim Fawcett CSE776 – Design Patterns Summer 2003
Out-of-Process Components
Chapter 8 - Design Strategies
Lecture 7 ATL and Out-of-Process Components
Jim Fawcett CSE775 – Distributed Objects Spring 2007
Automation and IDispatch
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Iterator Design Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Message Passing Systems
Presentation transcript:

Active Template Library Library support for building COM components CSE775 - Distributed Objects, Spring 2012 Jim Fawcett copyright © 1998-2012

Library Support for COM One of the difficulties with designing COM components with no support other than C++ is that COM does not support reuse through inheritance. This means that either you implement all the interfaces you need yourself, even the standard COM interfaces, or: You make your server a client of the standard COM component and use aggregation to provide access to the standard interface through COM aggregation – a very messy process. COM has addressed this problem with two types of support: The Microsoft Foundation Classes (MFC) provide extensive support for creating COM clients and servers. The Active Template Library (ATL) also provides a lot of support for creating COM servers and is generally preferred over MFC. Both libraries make it relatively easy to uses standard COM components without re-implementing them yourself.

Active Template Library (ATL) A diagram showing the structure of an ATL generated server is shown on the next page. The ATL CComObjectRootEx and CComObject classes, using templatized arguments you provide, implements the IUnknown interface and provides COM aggregation where needed. CComCoClass implements the server’s class factory. Classes with the name I…Impl implement standard COM components for you. Your code only needs to: provide template arguments for these classes Create a class that implements your server’s functionality, shown as CMyClass, and provide declarations for its interfaces, shown as IMyInterface Note that the ATL wizard will lead you through all this, so the process becomes quick and easy, if you understand how ATL works.

ATL Class Hierachy You won’t see this if you ask for a dual interface. You only see IDispatchImpl templatized on IMyInterface.

ATL Support for QueryInterface QueryInterface is implemented with map macros, much like the macros used in MFC programming: BEGIN_COM_MAP(myclass) COM_INTERFACE_ENTRY(IMyInterface) COM_INTERFACE_ENTRY(IDispatch) // here for dual interface END_COM_MAP() If you saw the expansion of these macros after preprocessing you would see a table-based process that supports QueryInterface via enumeration through table elements, one element for each interface.

ATL Support for COM Servers COM servers provide the following services: Register and unregister all classes in the server and the server and its type library. Provide the Service Control Manager (SCM) access to the class factories hosted by the server. Manage server lifetime.

CAtlDllModuleT

CAtlExeModuleT

ATL Support for Building Clients CComQIPtr<class T, const IID* piid = &__uuidof(T)>() Provides instance creation, lifetime management, query for interfaces CComBSTR(LPCSTR pStr) Wraps BSTRs, providing string manipulation functions, and memory management CComVariant(Type, VARTYPE) Wraps variants, used in Idispatch and for automation CComSafeArray<class T, VARTYPE>(count) Wraps arrays of variants

ATL Support for Windows Interfaces ATL provides, natively, support for creating both Frame and Dialog windows interfaces. When augmented with the wrappers in the (undocumented and unsupported) atlctrls.h, they provide a very useful framework for creating user interfaces. You have to know some Win32 windows programming, but they provide a lot of help. The classes used are shown in the diagram on the next page. If you want to create a highly functional, complex interface, then using WinForms or the MFC framework are good alternatives. However, ATL now provides additional support in the form of an add-on library call the Windows Template Library (WTL), available from sourceforge. We may discuss the WTL in more detail later in the semester.

ATL Windows

Active Template Library Microsoft has developed the Active Template Library (ATL) to support reuse of existing designs for many of the standard COM interfaces. IUnknown, IClassFactory, IDispatch, IMarshal ActiveX Controls interfaces event notification properties and property pages ATL provides source composition, not binary composition. Once built, however, ATL components, like any other, can be composed as binary objects. (we can add a binary control to a window, for example)

Some of the ATL Files AtlBase.h Low level type and class definitions AtlCom.h COM object management AtlConv.h Convert strings to/from unicode AtlCtl.h, AtlCtl.cpp ActiveX control support AtlComCli.h Smart pointers and BSTR wrapper AtlSafe.h SafeArray wrapper AtlSync.h Defines classes for locks Atlimpl.cpp Implementation of pieces too big to inline AtlWin.h, AtlWin.cpp Support for frame and dialog windows Statreg.h, Statreg.cpp Support for registry code

End of ATL Presentation