Microsoft에서 COM(Computer Object Model)는
쉽게 말해, 런타임동안 별개의 프로그램이 상호작용하기위해서 재사용가능한 소프트웨어라이브러리를 만드는 것에 대한 바이너리 단의 상호운용성 표준을 정의한 것이다.
상호운용성이란, 별도의 노력없이 서로 다른 프로그램하고 소통할 수 있는 여부에 대한 이야기이다.
Introduction to COM
The Microsoft Component Object Model (COM) defines a binary interoperability standard for creating reusable software libraries that interact at run time. You can use COM libraries without the requirement of compiling them into your application. COM is the foundation for a number of Microsoft products and technologies, such as Windows Media Player and Windows Server.
COM defines a binary standard that applies to many operating systems and hardware platforms. For network computing, COM defines a standard wire format and protocol for interaction among objects that run on different hardware platforms. COM is independent of implementation language, which means that you can create COM libraries by using different programming languages, such as C++ and those in the .NET Framework.
The COM specification provides all of the fundamental concepts that enable cross-platform software reuse:
- A binary standard for function calls between components.
- A provision for strongly-typed groupings of functions into interfaces.
- A base interface that provides polymorphism, feature discovery, and object lifetime tracking.
- A mechanism that uniquely identifies components and their interfaces.
- A component loader that creates component instances from a deployment.
COM has a number of parts that work together to enable the creation of applications that are built from reusable components:
- A host system that provides a run-time environment that conforms to the COM specification.
- Interfaces that define feature contracts, and components that implement interfaces.
- Servers that provide components to the system, and clients that use the features provided by components.
- A registry that tracks where components are deployed on local and remote hosts.
- A Service Control Manager that locates components on local and remote hosts and connects servers to clients.
- A structured storage protocol that defines how to navigate the contents of files on the host's file system.
Enabling code re-use across hosts and platforms is central to COM. A reusable interface implementation is named a component, a component object, or a COM object. A component implements one or more COM interfaces.
You define a custom COM library by designing the interfaces that your library implements. Consumers of your library can discover and use its features without any knowledge of your library's deployment and implementation details.
Objects and Interfaces
A COM object exposes its features through an interface, which is a collection of member functions. A COM interface defines the expected behavior and responsibilities of a component, and it specifies a strongly-typed contract that provides a small set of related operations. All communication among COM components occurs through interfaces, and all services offered by a component are exposed through its interface. A caller can access only the interface member functions. Internal state is unavailable to a caller unless it is exposed in the interface.
Interfaces are strongly typed. Every interface has its own unique interface identifier, named an IID, which eliminates collisions that could occur with human-readable names. The IID is a globally unique identifier (GUID), which is the same as the Universally Unique ID (UUID) defined by the Open Software Foundation (OSF) Distributed Computing Environment (DCE). When you create a new interface, you must create a new identifier for that interface. When a caller uses an interface, it must use the unique identifier. This explicit identification improves robustness by eliminating naming conflicts that would result in run-time failure.
When you define a new interface, you can create an interface definition by using the interface definition language (IDL). From this interface definition, the Microsoft IDL compiler generates header files for use by applications using the interface, and source code to handle remote procedure calls. The IDL supplied by Microsoft is based on simple extensions to DCE IDL, an industry standard for Remote Procedure Call (RPC)-based distributed computing. IDL is a tool for the convenience of the interface designer and is not central to COM interoperability. With IDL, you do not need to create header files manually for each programming environment. For more information, see Defining COM Interfaces.
Inheritance is used sparingly in COM interfaces. COM supports interface inheritance only to reuse a contract associated with a base interface. COM does not support selective inheritance; therefore, if one interface inherits from another, it includes all of the functions that the base interface defines. In addition, interfaces use only single inheritance, instead of multiple inheritance, to obtain functions from a base interface.
COM is a technology that allows objects to interact across process and computer boundaries as easily as within a single process. COM enables this by specifying that the only way to manipulate the data associated with an object is through an interface on the object. When this term is used in this documentation, it refers to an implementation in code of a COM binary-compliant interface that is associated with an object.
COM uses the word interface in a sense different from that typically used in Visual C++ programming. A C++ interface refers to all of the functions that a class supports and that clients of an object can call to interact with it. A COM interface refers to a predefined group of related functions that a COM class implements, but a specific interface does not necessarily represent all the functions that the class supports.
Referring to an object implementing an interface means that the object uses code that implements each method of the interface and provides COM binary-compliant pointers to those functions to the COM library. COM then makes those functions available to any client who asks for a pointer to the interface, whether the client is inside or outside of the process that implements those functions.