Keywords: malloc wxWidgets OpenGL polymorphism doxygen com Principle and Application ---- Automation Object. 1. Automation Technology Automation technology is previously mentioned in OLE automation. Although the automation technology is based on COM, it is more widely used than COM. On the one hand, automation inherits many advantages of COM, such as language independence and process transparency. On the other hand, automation simplifies some underlying details of COM, for example, processing attributes and methods, and a group of data types dedicated to automation. Automation is also the foundation of OLE, so we can regard automation as a technology between COM and Ole. The core of automation is the idispatch interface. Each Automation Object must implement the idispatch interface. Automation technology is not complex. It is actually a special case of COM. 2. automated production and development The language independence of COM is very limited when using some weak advanced languages, and automation provides anotherProgramAn intuitive and friendly way to communicate with each other. The development of automation technology is directly related to Visual Basic and VBA. First, VBA (or VBScript) has developed into a standard for most Microsoft Application Extensions. Second, the successful application of Microsoft Visual Basic development tools has also promoted the development of automation objects. Automation technology provides a shortcut for Visual Basic and collaborative development in other languages. Through automated programming interfaces, communication between different applications can be performed at the VBA or VBScript level, or even the concept of column set and RPC call is not required at all. Automation is a component technology located at the upper layer (Application Layer). It can be applied to end users, such as macro programming. The idispatch interface of the automation object can be used as the standard interface of OLE. Because OLE already provides standard interface proxy and stub components, the automation object can be run in the DLL component, you can also run it in the EXE component. In a distributed environment, automated objects can be created or connected by remote customers. 3. attributes and Methods Methods and properties are two basic features of automated objects. Methods refer to the functional services provided by automated objects, and properties refer to the data features of automated objects. Keywords: malloc wxWidgets OpenGL polymorphism doxygen com Principle and Application ---- Automation Object. In essence, an attribute is a value that can be set or obtained. Methods are much more flexible than attributes. They can have zero or multiple parameters. They can both be set and get object data. The most common thing is to complete some actions. The attributes and methods of an Automation Object have symbolic names, and the customer program can access the attributes or methods of the automation object through the name. 4. Type Library and odl The type information of a component object refers to the necessary information for its interaction with the outside world, including the CLSID of the component, the IID of the interfaces supported by the component, each member function of the interface, the parameters of the member function, and the return value type, the data types in the type information can also be custom data types, such as the C-language structure, union, and enumeration. Microsoft expands IDL to form odl (Object Description Language), which can describe the type information of component objects. Generally, the type information of a component object includes the type information of each interface and the type information of the object. The description method of the interface type information is fully compatible with IDL. The interface type information is described by the interface or dispinterface keyword, and the object type information is described by the coclass keyword. Each odl file can describe multiple component objects. The Type Library can be compiled by midl or mktyplib. Generally, all objects in a component program are put in an odl file, and library information is described with the library keyword, including the type library ID (Libid) the language and version used by the Type Library. You can also use importlib to introduce other types of information in the odl file. Compile the odl file with the midl utility to obtain the type library file. Its suffix is TLB, and the corresponding. h header file can also be generated. There are two advantages of using a Type Library. First, VB or VBA can use the Type Library to browse the methods and Properties of component objects. It can also use the Type Library to enhance access to properties and methods; second, when implementing the idispatch interface of the automation object, the Type Library can be used to provide the type information to the customer program, which can avoid tedious type processing. Keywords: malloc wxWidgets OpenGL polymorphism doxygen com Principle and Application ---- Automation Object. 5. idispatch Interface The member function invoke is a key function. The client program must use the invoke function to access attributes or methods. It can also be said that the invoke function is the command translator of the automation object. 6. automatically compatible data types The basic data type used by automation objects is the vcriant structure type. The entire variant structure is 16 bytes in size, but it describes the data types that can be used by all automated objects. 7. idispatchex Interface The type information described by the idispatch interface is static and will not be changed during the running process. All the type information can be obtained through the Type Library at the time of compilation. However, in some scripting languages, we need to provide type information dynamically at runtime. The idispatchex interface is established to meet these requirements and inherits the member functions of the idispatch interface. 8. Automated object implementation-type library support 9. Automated object implementation-invoke function implementation 10. Automated object implementation-Exception Handling 11. Automation Object implementation-multilingual and localized 12. Automated object implementation-use the createstddispatch function to implement automated objects 13. Automated object applications-dual Interfaces The automation controller can call all methods and attributes of the automation object through the idispatch interface. However, because such calls are carried out indirectly through the invoke member function, several duplicates are processed in the middle, the call efficiency is greatly reduced. Of course, this method provides great convenience for client programs in advanced languages. However, some client programs do not necessarily want this kind of efficiency loss. It wants to call member functions directly through vtable.Code. To meet both of these conditions, the automation object can expose methods and attribute functions by using the methods of interface member functions on the basis of implementing the idispatch interface, this forms the concept of dual interface. 14. Automated object application-late binding and early binding Because the automatic object uses the Type Library to check the parameter type, and the type library file is independent from the automation component, not only can the Automatic Object use the Type Library to implement its idispatch member function, the automatic controller can also use the Type Library to check the parameters of methods or attributes. If the automatic controller checks the parameter type and return value type at the time of compilation using the object type library, and calls the invoke function directly with the distribution ID, we call this call method early binding technology. Correspondingly, the controller can also obtain type information through the member functions of the idispatch interface at runtime. When it accesses an attribute or method, it must call idispatch: getidsofnames, in order to find the distribution id based on the symbolic name, we call this call called the late binding technology. The choice of early binding or late binding depends on the running environment of the controller, and the call efficiency is not the basis for judgment. 15. Automated object applications-automated set objects A collection object is also an automated object, but it has some special requirements. First, as a set of container objects (or numeric values) of the same type, it must provide methods to enumerate these members; secondly, it must support the add, remove, and item methods and the Count attribute. 16. Automated object application-An idispatch as an output interface 17. Automated object application-automated Controller 18. Automated object programming-MFC support for automated objects 19. Automated object programming-coledispatchdriver class 20. Automated object programming-use automated objects in Visual Basic |