Symbian OS advanced development-ECOM

Source: Internet
Author: User
Symbian OS advanced development-ECOM

In C ++, abstract classes and virtual functions mean that the program can call or invoke classes without knowing the specific implementation. This mechanism allows implementation after the interface is defined. This implementation is called a plug-in. In Symbian OS, ECOM is a general plug-in framework. It provides a simple mechanism for registration and query interface implementation, selects the appropriate implementation, and provides plug-in version control. Let's take a look at the essence of the plug-in system before introducing how ECOM can accomplish these tasks.

 

A client program wants to access an object for some processing. The specific implementation of this object is unknown until it is run. We only know the general features of processing and the definition of interfaces, and these processes have different changes under the same interface. Such a system has four clearly defined roles, that is, the customer program requesting the service, how to request the Service Interface Definition, provide the interface implementation for processing the request, and provide the framework for the specific implementation (instantiation) of the client program access. As shown in:

 

 

Figure 1 plug-in Diagram

 

Instantiation is the core of such a system. It is responsible for providing recognized services and loading the correct interface implementation during runtime. ECOM is such a framework. Next we will learn about ECOM from the interface client, interface implementation, and interface definition.

 

Interface client

The client program of the plug-in framework uses the C ++ interface provided by the framework to implement ECOM. No additional steps are required except for the following steps:

Link the library file ECOM. Lib of the ecom framework
Include interface definition file
Obtain an object through the newl method of the interface. Generally, the client program Transmits some data to indicate the characteristics of the required object.
Objects used
Delete an object after it is used
Call the recomsession: finalclose method to clear memory usage
 

Because the Framework provides most of the functions, the interface client does not need to do much work. You only need to call the interface, but the memory recycle and cleanup operations are an exception. To ensure proper uninstallation when not in use and release the memory used, the client should follow the following rules:

Delete the instantiated objects obtained from interfaces when they are not in use.
For processes such as services, applications, and test programs, the recomsession: finalclose method must be called before exiting to enable the ECOM framework to perform final clearance. This method can be called only after all instantiated objects are deleted.
If ECOM is used in the library file, the recomsession: finalclose method should be called in the exit function of the library file.
 

Note that the finalclose method cannot be called in the destructor of the interface or plug-in class.

 

Interface Definition

Interface Definition has two purposes: one is to define functions for the use of the client. These functions are usually pure virtual functions, which are derived from them by the implementer to provide specific functions; another purpose is to provide the Object Instantiation function. This function does not create an interface class's own instance, but uses ECOM to create an appropriate implementation instance and return it to the customer program. The interface notifies the ECOM object that the structure has been destructed.

 

Generally, an interface is defined as ECOM that provides the recognition of available implementations. This recognition can be explicit. For example, a uid indicates a special implementation, which can also be indirect, for example, use data to match the self-description of implementation. This selection process is called Resolution, and the executed entity becomes resolver. ECOM provides a default resolver, but the interface definition can provide its own resolver as needed.

 

Interface implementation

An interface implementation provides services agreed on by the interface, and is implemented in the C ++ standard mode, derived from the base class. One or more interface implementations are concentrated in one DLL, called an interface implementation set. A set can have multiple interfaces. Each set has two key functions for ECOM:

Export the array of a factory function so that the implementation can be created
Publish a registered resource file to list all implementations and attributes
 

ECOM architecture security

The security architecture of Symbian OS provides protection against malicious and illegal code, ensuring the security of the platform. The following are some aspects related to platform security and ECOM plug-in Architecture:

Capability Model of platform security, which prevents processes from loading and using DLL files that are less secure than themselves.
Control Software Installation to ensure that the installed software cannot be damaged.
Control Process access to special files.
In ECOM, the plug-in is a DLL. When the DLL provided by the interface is instantiated, it is loaded to the client process, if the plug-in DLL capability (capability) the system reports a rejected request error (-46) if it is less capable than loading the process ).

 

The plug-in provider must consider the following security factors:

If a plug-in is provided, the plug-in can only be loaded and used by a client process without the ability.
If the plug-in is only used by a program, the document of the program should provide the required capabilities.
If you want to enable the plug-in to be used by all programs (except the kernel and file service), you should set the plug-in to TCB, which is fully capable. Of course, such a high capability needs to be passed through Symbian sign.
The resolver plug-in is a special case. It is loaded by a service process of ECOM, so it must be trusted by the Service. In this case, the plug-in must have the protserv capability.
The platform security architecture strictly requires that all executable code, including plug-ins, be stored in the/sys/bin/directory, and access to this directory is restricted. Only a few system processes can access this directory. In addition, the resource files required by the plug-in are installed in the/resource/plugins/directory.

 

ECOM framework Summary

The ECOM framework represents an interface definition that provides the ability to parse (RESOLVE) at run time and load appropriate implementations. It is a client server structure and has a single-piece model of the Client Session class recomsession, this class has the functions of creating, destroying, and enumerative implementations, and the server controls the registration and loading of implementations.

 

As mentioned above, the Framework provides a default resolver to select an appropriate implementation. The interface can create the most suitable implementation by asking the framework, or return a list Of all matching implementations, select an appropriate implementation using other methods.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/pursuer_zhao/archive/2009/03/28/4032133.aspx

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.