Build your own C/C ++ plug-in development framework (I)-preliminary ideas

Source: Internet
Author: User

I have been learning osgi knowledge recently. I bought an osgi principle and Best Practices book, but I haven't got it yet. Unfortunately, several open-source frameworks of osgi currently only support Java and do not support both C and C ++. Unfortunately, the main development languages of our company are C and C ++. Even if osgi is introduced, the benefits are limited. I have long been yearning for the loosely coupled modular development. It seems that osgi has an open-source project for C ++ support, but it seems that the application scope is small. The SCA standard supports the C ++ implementation model, but several open-source frameworks currently only support Java.

Yesterday I saw Ding Liang's reposted blog 《C/C ++: build your own plug-in framework, The original link: http://blog.chinaunix.net/u/12783/showart_662937.html. I have read the method mentioned in it, but I can implement it myself. So I had the idea of building my own C/C ++ plug-in development framework. Today, let's write a preliminary idea.

Elements of the C/C ++ plug-in development framework

Bluedavy has an article about the elements of the service framework.Article(Link: http://www.blogjava.net/BlueDavy/archive/2009/08/28/172259.html ). My plug-in framework should also consider and solve the following problems:

1. Register a plug-in;

2. How to call the plug-in;

3. How to test the plug-in;

4. lifecycle management of plug-ins;

5. Management and Maintenance of plug-ins;

6. Plug-in assembly;

7. Agent error handling;

8. Broadcast and subscribe to service events (this is not yet considered for support );

Among them, there are several important points: 1) the plug-in framework should be able to make the modules loosely coupled for real interface-oriented programming; 2) the framework should support automated testing, including unit testing and integration testing; 3) Simplified deployment; 4) Support for distributed deployment. modules can call plug-ins outside the framework.

Technologies used
One problem to be solved by the plug-in framework is the dynamic loading capability of the plug-in. The dynamic loading technology of shared libraries can be used here. Of course, for simplicity, the first step is to consider only a plug-in framework under Linux.

Overall Structure

For the overall structure of the Framework, refer to the osgi "microkernel + system plug-in + application plug-in" structure. Here, we should consider what to do in the kernel. With regard to the microkernel structure, I used to create a microkernel process engine and will share it with you later.

There are two solutions for inter-module data transmission in the framework: first, the XML data bus approach adopted by panyuan. The advantage is good scalability and readability. However, the speed is slow. The second is to use cell streams that I am familiar. The advantage is high efficiency, convenient access, but less readable. In addition, the network byte sequence needs to be considered for cross-framework data transmission.

For inter-framework communication, the system plug-in is encapsulated to hide the communication details of the application plug-in.

Deployment

One-click deployment.

Related Article

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.