COM principle and application----can connect objects

Source: Internet
Author: User

1. Advanced Features of COM

There are some advanced features in the COM specification, such as connecting objects, permanent storage, consistent data transfer, and so on, so that the COM specification has more vitality, they are also the basis of OLE, but their applications are not limited to OLE, these advanced features have been widely used on Windows operating systems.

2, into the interface, out of the interface and receiver

The inbound interface (incoming interface) is an interface that the component exposes to the customer, passively listens to and responds to customer requests. The outbound interface (outgoing interface) refers to the interface in which the component actively communicates with the customer.

The interface is not implemented by the object, but is implemented by the client, the client implements these interfaces, and the interface pointer is told to the object, and the object uses this interface pointer to communicate with the customer later. On the client side, the object that implements these interfaces is called the receiver (sink). The receiver itself is also a COM object, but it is often simpler and is used only to listen for notifications or requests to process component objects.

The relationship between the customer and the object is relative, and the inbound and outbound interfaces are a relative concept that is used only in one direction of communication.

3, can connect the object

If a COM object supports one or more outbound interfaces, it is said that such an object is a Connectable object (object), or is referred to as source.

The outbound interface for a connected object is also a COM interface that contains a set of member functions, each representing an event, a notification (notification), or a request.

4. Events, notices and requests

Events and notifications are conceptually identical, it is only used on different occasions, for example, when a property is changed in a COM object, it can send a notification to the customer, and the client can handle the event when a particular event occurs, such as when a timed message or a user mouse action occurs. However, the concept of the request is slightly different, and the object makes a request to the customer, and it expects the customer to provide some information and expect the customer to respond.

In the sense of the COM specification, both events, notifications, and requests are implemented through the member functions of the interface.

5, customer and the relationship of the object can be connected

Although the receiver is also a COM, but it has specificity, it is located inside the client program, does not need to be created through the COM library, so the receiver does not need a CLSID to identify, and do not need a class factory, the receiver's identification and creation process is entirely within the client program. To the outside of the client, the receiver is also a separate COM object, it has its own reference count, its own interface query method, that is, the QueryInterface member function. COM only requires the receiver to be a stand-alone COM object, and the COM specification has no restrictions on the implementation of the sink.

A generally accessible object should not request additional interfaces to the receiver object, that is, the QueryInterface member function of the receiver should not be invoked. The receiver is usually dedicated to an out interface pointer, and the receiver object implements only the interface, except that the interface is a base interface (for example, IUnknown).

The connection object and the receiver can form a one-to-many or many-to-many relationship, i.e. the relationship between the client and the connected object can be One-to-many or many-to-many.

6, the basic structure of the object can be connected

A connected object can support one or more outbound interfaces, which manage the interfaces IConnectionPointContainer through the interface. For each outbound interface, the connected object manages an object called a connection point (connection points), and each connection point object implements the IConnectionPoint interface, and the client establishes a connection between the receiver and the connected object through the connection point object. A connection point can access internal information about a reachable object, or access a client's sink, and other reference counters that can directly use a connected object.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.