Chapter III

xiaoxiao2021-03-06  55

Talk again to interface and implementation

Interface: Abstract protocol of objects for communication.

Implementation: Supports a specific data type of one or more interfaces.

Class: Named implementation. It represents a specific type of objective, called COM class or CoClass

CLSID is used to name implementation, COM also supports textual approach PROGID, using a set of COM APIs to achieve mutual conversion

Class object

One basic requirement for all COM classes is that they must have a class object. (Class Factory)

For each class, the class object is unique, it implements the creation function of the class.

activation

Three activation models: Bind to class objects (required), bind to class instance, bind to permanent instances from files

SCM is a central control point for all activation requests on a machine. Any local SCM on each host that supports COM, which forwards to the SCM on the remote machine, and this activation request will be Treat it as a local activation request.

The SCM is only used to activate objects and binding initial interface pointers. Once an object has been activated, the SCM no longer intervenes into the method call between customers and objects.

SCM is implemented by RPCSS

Objects are activated in the customer, and the DLL that implements the object method will be loaded into the customer process, which makes method calls very efficient.

Objects In another process (local or remote) is activated, the code to implement the object method will perform objects in the server process, all data members reside in the server process address space, COM transparently returns a proxy when it is activated Object, run in the customer thread, call the method to translate the method to the actual object

Use SCM

Hierarchy: Bind to class objects (required, bottom) <- Bind to class instance <- Bind to a permanent instance from files

COM API COGETCLASSOBJECT () Get class objects, then use class objects to get objects.

Class and server

COM records a configuration database (NT directory), COM uses class storage (information of the COM class) to resolve the CLSID to the implementation file name

Registry Related: DllRegisterServer, DllunregisterServer

DLL leads to DllgetClassObject for CogetClassojBect call

generalization

Interface for object discovery: ioleitemcontainer

Interface for objects created: iClassFactory

optimization

COM API: CocreateInstanceex contains the functionality of COGETCLASSOBJECT and ICLASSFAACTORY :: CreateInstance.

Customers will not see class objects, QueryInterface is performed inside class objects and improves performance.

And allow customers to request multiple interface pointers to new objects

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

New Post(0)