Microsoft COM - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Microsoft COM

Description:

Do you rebuild your car when you. change your tires? COM. The Component Software Problem ... COM defines a standard way to lay out the virtual function tables ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 23
Provided by: ashishk9
Category:
Tags: com | microsoft

less

Transcript and Presenter's Notes

Title: Microsoft COM


1
Microsoft COM
  • Component Object Model

Ashish Kasturia ashish_at_yakko.cs.wmich.edu
2
Agenda
  • Introduction
  • Overview
  • The Component Software Problem
  • COM features
  • COM standard comes to the rescue
  • Client/Server model
  • Inheritance and reusability
  • OLE, ActiveX, DCOM
  • Samples
  • Miscellaneous
  • Summary
  • References
  • Questions

3
Introduction
  • The history of software development
  • The beginners way - procedural way
  • Object oriented way
  • The DLL hell problem.
  • The COM way of developing software.
  • Code reuse vs. object reuse

4
Overview
  • for(i 0 i lt 100 i)
  • printf(Hello World!)

printf(Goodbye World!)
gcc .cpp compiling 1000 files ...
gcc .cpp compiling 1000 files ...
Why do you have to recompile the entire project
when you change a small module?
5
The Component Software Problem
  • Interoperability
  • Making components from independent vendors work
    with each other.
  • Version problem
  • Upgrading the component, without recompiling the
    entire project.
  • Language independence
  • Platform independence

6
COM features
  • A binary standard between components.
  • Grouping of functions into Interfaces
  • Uniquely identify Interfaces and components.
  • Ways for components to dynamically discover
    Interfaces of other components.
  • Ways for components to track their own lifetimes.

7
COM features
  • A binary standard between components.
  • COM defines a standard way to lay out the virtual
    function tables (vtables) and a standard way to
    call functions.

Client variable
8
COM features
  • Grouping of functions into Interfaces
  • An interface is a strongly typed contract between
    components to provide a small and useful set of
    semantically related methods.
  • The interaction between components is done only
    through interfaces.
  • So, only the methods can be called, but data
    cannot be modified.

9
COM features
  • More about Interfaces
  • Interface is a set of related methods in a
    component.
  • Components can have multiple interfaces.
  • Interfaces are strongly typed.
  • Every interface is uniquely identified by a GUID.
  • Interfaces are immutable.

10
COM features
  • More about Interfaces

In this case, the object supports 3 interfaces -
A, B and Iunknown. Client uses Interface A.
11
COM features
  • Uniquely identify Interfaces and components.
  • Global Unique Identifiers (GUIDs) are 128 bit
    integers and are used to identify the interfaces
    and component objects.
  • GUIDs are UUIDs (universally unique IDs) as
    defined by the Open Software Foundation's
    Distributed Computing Environment.

E.g. IUnknown - 00000000-0000-0000-C000-000000000
046 IIDs found under HKEY_CLASSES_ROOT\Interface
12
COM features
  • Ways for components to dynamically discover
    Interfaces of other components.
  • All the interfaces have to be derived from
    IUnknown interface.
  • IUnknown interface has three methods called
    QueryInterface, Addref and Release.
  • QueryInterface method is used to query for other
    interfaces.

hr ppB-gtQueryInterface(IID iidA,void
ppA) hr ppA-gtMethodA() hr
ppA-gtQueryInterface(IID iidB,void ppB)
13
COM features
  • Ways for components to track their own lifetimes.
  • Done via Addref and Release methods.
  • Whenever a client uses an interface, Addref is
    called. When the client no longer requires the
    interface, Release is called.
  • In this way, a reference count is maintained by
    the object.

14
COM standard comes to the rescue
  • Interoperability
  • Standard use of vtables.
  • Versioning.
  • Each component can be updated without any effect
    on the rest of the application.
  • Language independence
  • COM represents a binary standard, as opposed to
    source code standard.
  • Platform and local/remote transparency.

15
Client/Server model
  • The components behave as servers, serving
    interfaces to clients.
  • If a client requests an interface that isnt
    supported by a server, E_NOTIMPL is returned and
    the client handles the situation accordingly.
  • If a server crashes, the client can gracefully
    handle the situation.

16
Inheritance and reusability
  • Implementation inheritance in component
    development is not a good idea.
  • COM provides containment/aggregation.

17
OLE, ActiveX, DCOM
  • Automation as defined by MSDN A way to
    manipulate an application's objects from outside
    the application. E.g OLE, ActiveX.
  • It uses IDispatch interface to get the methods
    and the object properties. In/out variables
    specified in IDL.
  • DCOM it is COM with a longer wire, uses proxy
    and stub interfaces and works on remote servers
    and clients.

18
Samples
  • Making a simple COM component in VC.
  • Adding automation capabilities.
  • Using the object in VB.
  • Using the object in VC.
  • Using the regsvr32 utility

19
Miscellaneous
  • Security
  • Communications between components, even across
    process and network boundaries.
  • Shared memory management between components
  • Error and status reporting - HRESULT
  • How does VB use it?
  • COM on Linux/Unix?

20
Summary
  • COM solves the Component Software problem.
  • Imposes standards on the way components interact
    with each other (same process, different
    processes or remote components).
  • Allows the components can be built by independent
    vendors.
  • Allows for upgrading the components without any
    effect on other components.

21
References
  • MSDN Library Visual Studio 6.0 release
  • The Component Object Model A Technical Overview.
  • COMponents.
  • Dr. GUIs articles.
  • Microsofts COM website
  • IDevResource.com COM channel - COM on Linux by
    Frank Rem
  • IDevResource.com - What COM is all about

22
Question?
Write a Comment
User Comments (0)
About PowerShow.com