COM objects and interfaces

zhaozj2021-02-17  55

We will introduce the COM specification, especially the agreement used by the COM, which is the core of the COM standard. The COM interface is based on the standard in binary level. Some advanced features such as multi-threaded models, distributed COM, etc. are based on this. 2.1 COM object COM is an object-oriented component model. The COM is provided to the customer is an entity that is encapsulated in an object. 2.1.1 Symbol of the COM object - The location of the CLSID COM component is transparent to the customer because the customer does not access the COM component directly, and the client program creates and initializes the object through a global flag. But how to guarantee uniqueness without central institutional management is the point of resolution of the flag. To this end, COM uses a 128-bit global unique marker. Below is an example of a Guid {54Bef6567-1007-11D1-B0AA-4445535540000} Randomness is guaranteed by two aspects: one aspect is space, on the other hand. The COM library provides us with the following API function that can generate GUID: HRESULT COCREATEGUID (GUID * pguid) ;. CLSID is a GUID used to mark COM objects. 2.1.1 Comparison of COM objects and C objects 1. Packaging features In COM objects, data is fully encapsulated inside the object, and externally impossible data properties directly access objects. Access the properties of the object through the interface member function provided by the COM object and the client program. The encapsulation of the data member of the COM object is based on the component as the final boundary. For object users are completely transparent, invisible; and the package characteristics of C objects are only semantically encapsulated, which is visible to the object users. 2. Reusability of Reusability COM objects Performance in the inclusion and aggregation of the COM object, one object can fully use all functions of another object; and the reusability of the C object is inherited in the C class inheritance, derived class Call the non-private member function of his parent class. 2.2 The interface between COM interface components is critical. The core content of the COM specification is the definition of the interface. 2.2.1 From the API to COM interface 2.2.2 Interface definition and flag interface is a data structure that contains a set of functions. With this group of data structures, customer code can call the component object. The client uses a pointer to an interface data structure to call the interface member function. The interface pointer actually points to another pointer, the second pointer points to a set of functions, becoming an interface function table. Each of the interface function tables is a 4-byte function pointer, and each function pointer is associated with the specific implementation of the object. The COM interface also uses a global unique marker, which is called the interface flag (IID, Interface Identifier 2.2.3 Using C language definition interface 2.2.4 Interface Description Language IDL COM Specification In using OSF DCE specification Description Remote call interface Based on the IDL (Interface Description Language), the extension forms a description language of the COM interface. 2.2.5 Interface Memory Model 2.2.6 Interface Some Features 1. Binary Features 2. Interface Impractive 3. Inheritance (Scalability) 4. Polymorphism - Polymorphism during the operation

转载请注明原文地址:https://www.9cbs.com/read-30948.html

New Post(0)