A method for information interaction based on meta-object invocation mechanism under QT platform

By using the meta-object invocation mechanism under the QT platform, adopting a lightweight data storage structure and a clear information transmission channel, the problems of low information interaction efficiency and complex problem location are solved, achieving efficient information interaction and easy traceability.

CN116431370BActive Publication Date: 2026-11-10713 RES INST OF CHINA SHIPBUILDING IND CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211551363.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-05
Publication Date
2026-11-10
Estimated Expiration
2042-12-05

AI Technical Summary

Technical Problem

Existing information interaction technologies suffer from low information interaction efficiency, difficulty in business expansion, and complexity in problem localization.

Method used

The system adopts a meta-object-based invocation mechanism under the QT platform. By setting service parameters, service mapping relationships, interface link mapping relationships, and instance mapping relationships, the information request end sends request information, and the information processing end calls the singleton method based on the meta-object invocation mechanism to obtain interactive information. Serialization and deserialization are achieved through a lightweight data storage structure.

Benefits of technology

It improved the efficiency of information exchange, simplified the problem localization process, reduced the workload of problem localization, and enhanced the traceability and transmission efficiency of information exchange.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116431370B_ABST
    Figure CN116431370B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of information interaction technology, specifically relating to an information interaction method based on a meta-object invocation mechanism under the QT platform. The method includes: an information requesting end sending request information in a predetermined data format through a set sending mechanism; the request information includes interface link information and service parameters; an information processing end obtaining corresponding class information and method information from the interface link mapping relationship based on the interface link information, and obtaining the corresponding singleton from the instance mapping relationship based on the class information; invoking the method corresponding to the method information through the singleton based on the meta-object invocation mechanism, and setting the service parameters to the parameter values ​​of the method; the method corresponding to the method information is macro-defined. In the information feedback end, this method obtains a service singleton of the service class based on the service mapping relationship, drives the service singleton to call the set service method to obtain interaction information based on the service parameters, and then feeds back the interaction information. Thus, this invention solves the problems of low information interaction transmission efficiency and complex problem tracing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information interaction technology, specifically relating to an information interaction method based on a meta-object invocation mechanism under the QT platform. Background Technology

[0002] With the continuous development of computer information technology, the need for dynamically displayed information has become increasingly apparent, and the resulting information interaction has become a hot research topic.

[0003] To better meet user experience needs, information interaction requires timeliness, accuracy, and diversity. Therefore, lightweight and visualized data models have become the preferred medium for information interaction among researchers. To better achieve the goal of easy problem traceability, information interaction needs to be easy to locate and track problems. Therefore, the establishment of information interaction models has become a key focus of information interaction research.

[0004] Most existing information interaction technologies use custom objects and XML as data storage structures, then rely on numerous if and switch statements to match corresponding business logic. On one hand, both custom objects and XML involve additional factors during serialization and deserialization, such as the need to implement certain interfaces, and the compiler needing to consider attribute types and structural forms, which can limit interaction efficiency to some extent. On the other hand, when problems arise in existing information interaction technologies, it is necessary to continuously debug and trace to locate the problem, requiring investigation of multiple nodes, significantly increasing the workload.

[0005] Therefore, existing technologies suffer from problems such as low information exchange efficiency, difficulty in business expansion, and complexity in problem localization. Summary of the Invention

[0006] The purpose of this invention is to provide an information interaction method based on the meta-object invocation mechanism under the QT platform, so as to solve the problems of low information interaction transmission efficiency and complex problem tracing in existing information interaction technologies.

[0007] To solve the above-mentioned technical problems, the technical solution provided by this invention and the corresponding beneficial effects of the technical solution are as follows:

[0008] The present invention provides an information interaction method based on a meta-object invocation mechanism on the QT platform, comprising the following steps:

[0009] 1) Define service parameters, service mapping relationships, interface link mapping relationships, and instance mapping relationships; service parameters are used to filter the interaction information of requests; instance mapping relationships are used to represent the mapping relationship between each type and its corresponding singleton; each type is used to call its corresponding service class and return the interaction information obtained by the service class; service mapping relationships are used to represent the mapping relationship between each service class and its corresponding service singleton; each service class is used to obtain the corresponding interaction information based on the service parameters; interface link mapping relationships are used to represent the mapping relationship between each interface link information and the class information and method information used in the corresponding interface link;

[0010] 2) The information requesting end sends a request message with a set data format through a set sending mechanism; the request message includes interface link information and service parameters;

[0011] 3) The information processing end receives interface link information and service parameters; based on the interface link information, it obtains the corresponding class information and method information from the interface link mapping relationship;

[0012] Based on the class information, the corresponding singleton is obtained from the instance mapping relationship; the method corresponding to the singleton and method information is called based on the meta-object invocation mechanism, and the service parameters are set to the parameter values ​​of the method; the method corresponding to the method information is defined by macros;

[0013] 4) In the information feedback end, this method obtains a service singleton of the service class based on the service mapping relationship, drives the service singleton to call the set service method to obtain interaction information based on the service parameters, and feeds back the interaction information.

[0014] The beneficial effects of the above technical solution are as follows: The information request end of the present invention sends the information to be requested to the information processing end according to the set interface link and service parameters. The information processing end obtains the corresponding singleton through the instance mapping relationship, and calls the method corresponding to the method information through the singleton based on the meta-object invocation mechanism. The called method drives the service singleton to call the set service method and obtains the interaction information according to the service parameters. Finally, the called method feeds back the interaction information that meets the business requirements.

[0015] This invention employs a mapping relationship for data storage. During serialization and deserialization, only the corresponding mapping relationship needs to be considered, resulting in faster data serialization and deserialization compared to existing information interaction technologies, thus improving information interaction efficiency. This solves the problem of low information transmission efficiency in existing information interaction technologies. Furthermore, this invention is based on a meta-object invocation mechanism. This unique method call link allows for intuitive location of specific request information. When problems arise in information interaction, even in complex system programs, only the information request layer needs to be located. The request information issued through the information request layer can directly locate the corresponding mapping relationship, allowing for troubleshooting and repair within that relationship. This significantly reduces the workload of locating problems compared to existing information interaction technologies. Therefore, this solves the problems of difficult information traceability and low information transmission efficiency in existing information interaction technologies.

[0016] Furthermore, to improve the efficiency of information exchange, service mapping relationships, interface link mapping relationships, and instance mapping relationships are stored using key-value collections.

[0017] Furthermore, to facilitate data transmission, the set data format is a string.

[0018] Furthermore, the request information in string data format is obtained in the following way:

[0019] Encapsulate the interface connection information and service parameters into a JsonObject object; convert the JsonObject object into a string.

[0020] Furthermore, the method corresponding to the method information is defined by Q_INVOKABLE; in step 3), the invokeMethod function is used based on the meta-object invocation mechanism to implement the singleton invocation of the method corresponding to the method information.

[0021] Furthermore, the sending mechanism is set to a message queue. Attached Figure Description

[0022] Figure 1 This is an information interaction flowchart of an information interaction method based on a meta-object invocation mechanism under the QT platform according to the present invention;

[0023] Figure 2 This is a schematic diagram of the method for constructing a singleton in the method embodiment of the present invention;

[0024] Figure 3 This is a schematic diagram of initialization information in a method embodiment of the present invention;

[0025] Figure 4 This is a schematic diagram illustrating the functionality of the information request layer in the method embodiment of the present invention;

[0026] Figure 5 This is a schematic diagram illustrating the functionality of the information processing layer in the method embodiment of the present invention;

[0027] Figure 6 This is a schematic diagram illustrating the function of the information feedback layer in the method embodiment of the present invention;

[0028] Figure 7 This is a schematic diagram of the object-to-character conversion function in the method embodiment of the present invention;

[0029] Figure 8 This is a schematic diagram of the string-to-object conversion function in the method embodiment of the present invention;

[0030] Figure 9 This is a schematic diagram illustrating the information interaction principle in the method embodiment of the present invention. Detailed Implementation

[0031] The meta-object system is the most important core system in the Qt library. It provides signal and slot mechanisms, runtime type information, and dynamic attributes for communication between class objects. It can effectively extend the information call interface, intuitively troubleshoot and locate problems, and minimize code size, making it suitable for information interaction in various scenarios. Based on the above issues, a method for information interaction based on the meta-object invocation mechanism under the Qt platform is proposed.

[0032] The problem this invention aims to solve is the difficulty in information traceability and low information transmission efficiency in existing information interaction technologies. This invention provides an information interaction method based on a meta-object invocation mechanism on the QT platform. It achieves interactive information through a clearly defined information transmission channel (request information) and a lightweight data storage structure (mapping relationship), offering advantages such as easy problem troubleshooting and high interaction efficiency. Specifically, for example... Figure 9 As shown, this invention sets a path (interface link) for the interactive information under each service block, and sets parameters (service parameters) for each interactive information under that path.

[0033] The classes and methods corresponding to each path are stored through an interface link mapping relationship. To prevent management confusion, each class has a unique instance, which is stored through an instance mapping relationship. Each class is used to call its corresponding service class and return the interaction information obtained by the service class. Each service class is used to obtain the corresponding interaction information based on service parameters. Each service class is stored through a service mapping relationship. When obtaining interaction information, the information requesting end only needs to send the request information consisting of the path and parameters of the information to be interacted with to the information processing end. The information processing end uses the meta-object invocation mechanism to call the method corresponding to the method information through the singleton of the class. This method drives the service class to query the interaction information and return the interaction information.

[0034] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0035] Method Implementation Examples:

[0036] This invention provides an embodiment of an information interaction method based on a meta-object invocation mechanism on the QT platform. The invention mainly consists of two stages:

[0037] 1. Information preparation stage.

[0038] The information interaction process mainly involves interface links, control layers, and services. Interface links guide the path of specific business data, including classes and corresponding methods; the control layer is the unique instance corresponding to each class; and services are the classes used to obtain the corresponding interaction data. This invention divides a large amount of interaction data into multiple blocks based on specific functions, with each block containing multiple pieces of interaction data. Therefore, a service parameter is set for each piece of interaction data; and an interface link is set for each block of interaction data.

[0039] The method design divides data into the smallest granular units based on business requirements, with each interface link, instance, and service corresponding to unique interaction data. To better invoke business logic during the information interaction phase, information initialization is performed on three nodes: the interface link, the control layer, and the service, before the information interaction phase. These three nodes use a key-value set data format, where the key assigns a unique identifier to each interface link, control layer, and service, and the value is the specific value. During the information interaction phase, the corresponding value information is retrieved using the key, and then the next step of logic processing is performed.

[0040] When multiple instances access a key-value collection simultaneously, if one of the instances modifies the collection, the data read by the other instances will be stale, which will affect the business. Therefore, it is essential to ensure the uniqueness of instances.

[0041] 2. Information exchange stage.

[0042] Based on annotation principles, the information interaction process is designed with visual information request links and macro-defined methods that can be called by the meta-object system. The information request layer (information request end) defines information interaction links as guidelines for information interaction based on specific needs, locates the specific implementation method on the information receiving end, and then automatically matches the specific method based on the meta-object invocation mechanism and the interaction guidelines. Finally, a reflection mechanism is used to adaptively obtain the service and call the corresponding service for business processing.

[0043] In the information exchange phase, the information request layer and the information feedback layer are two inverse endpoints, and the direction of information exchange is bidirectional transmission. The information processing layer acts as an intermediate bridge between the two endpoints, distributing and processing information interfaces.

[0044] The above technical solutions mainly address the problems in existing information interaction technologies, such as the difficulty in tracing information, which makes it difficult to troubleshoot information interaction issues, and the low efficiency of information interaction transmission due to the complexity of data storage structure serialization and deserialization in information interaction.

[0045] The information interaction method based on the meta-object invocation mechanism under the QT platform of the present invention specifically includes the following six steps, as follows: Figure 1 As shown:

[0046] Step 1: Construct a Singleton. To prevent multiple control instances from reading and writing data to a single piece of interactive data, causing confusion and read / write errors, this embodiment uses a singleton approach to construct the control instance.

[0047] Because the interface links, controller (instance), and service classes need to ensure the continuity and uniqueness of the collected data, each class must guarantee that only one instance can be generated. Furthermore, to ensure thread safety, a mutex lock is used during instance creation to prevent multiple threads from creating instances simultaneously. Specifically, to ensure instance uniqueness and thread safety, a QMutex mutex lock is used for singleton construction. The construction process is as follows: Figure 2 As shown.

[0048] Step 2: Initialize information.

[0049] Initialization information primarily provides basic data support for information interaction. First, three Map collections are defined to store the mapping relationship between unique identifiers and their corresponding values: `interfaceLinkMap` (interface link mapping), `controllerInstanceMap` (instance mapping), and `serviceInstanceMap` (service mapping). Then, each of the three Map collections is initialized. `interfaceLinkMap` is used to define interface links, storing methods defined by macros and providing path guidance when calling internal logic. `controllerInstanceMap` is a collection of Controller instances, storing the mapping relationship between the class name of the Controller instance and its corresponding unique instance, providing instance support when calling internal logic. `serviceInstanceMap` is a collection of Services, storing the mapping relationship between the service name and the unique instance of the service to obtain the required business data, providing services for processing business logic in the Controller layer. The initialization information for the three Map collections, `interfaceLinkMap`, `controllerInstanceMap`, and `serviceInstanceMap`, is as follows: Figure 3 As shown, specifically, the key of interfaceLinkMap is "name" and the value is " / Controller / methodName", where "Controller" is the class name and "methodName" is the method name. The key of controllerInstanceMap is the class name and the value is the singleton instance corresponding to the class. The key of serviceInstanceMap is the class name and the value is the singleton instance corresponding to the class.

[0050] Step 3: Information Request Layer.

[0051] Based on specific business needs, a customized information request channel (request information) is created. This channel contains two types of information: first, an interface link, used to guide the information request. This link consists of two layers: a class name and a method name, separated by a " / ". Second, parameters. In the information request, parameter values ​​are used to filter and obtain interactive data that matches the specific business scenario. These parameter values ​​are also called service parameters. After defining these two types of information, the information is encapsulated into a JsonObject object. Then, the JsonObject object is converted into a string. The specific implementation of object-to-string conversion is as follows... Figure 7As shown, the converted string is ultimately sent to the information processing end of the server through a specific message sending mechanism. In this embodiment, a message queue is used as the specific message sending mechanism. The process of encapsulating information at the information request layer is as follows: Figure 4 As shown.

[0052] Step 4: Information Processing Layer (Information Processing Terminal).

[0053] The information processing layer parses and splits the data in the information request channel and calls the defined methods, as follows: Figure 5 As shown. After receiving the information, the receiving end first parses the information to extract the interface link and parameters. The parsing process begins by converting the string into an object; the specific implementation is as follows... Figure 8 As shown. Then, the interface link is split using the Split function to extract the class name and method name. Based on the class name, a unique instance of the class is obtained from the controllerInstanceMap collection. Then, based on the meta-object invocation mechanism, the method corresponding to the method name is invoked through the invokeMethod function. The invokeMethod function contains the class instance, the name of the method to be executed, the return value (identified by Q_RETURN_ARG), and the parameters (identified by Q_ARG).

[0054] Step 5: Information Feedback Layer (Information Feedback Terminal).

[0055] The macro definition methods of the information feedback layer and the process of calling the corresponding services are as follows: Figure 6 As shown, in the information feedback layer, all values ​​in the interfaceLinkMap collection are macro-defined using Q_INVOKABLE, enabling them to be called by the meta-object system. The return type of the defined method is consistent with the return type of the invokeMethod function in the information processing layer, and the parameter types are also consistent with the parameter types in the invokeMethod function.

[0056] The method body first converts the parameters into parameter objects. Then, based on the service name required by the business logic, it retrieves the corresponding service instance from the `serviceInstanceMap` collection. Next, the service instance performs relevant business processing at the service layer based on the parameter object and returns the data required by the information request layer. Finally, the data is sent to the information request layer using the same transmission channel, which is the aforementioned message queue. For example, ... Figure 9 As shown, the service layer includes several services used to retrieve various types of business data. In the request layer, data can be processed through the information processing layer based on the type name and its corresponding method name before being requested from the service layer.

[0057] In this invention, the information requesting end sends the requested information to the information processing end according to the set interface link and service parameters. The information processing end obtains the corresponding singleton through the instance mapping relationship, and calls the method corresponding to the singleton and method information based on the meta-object invocation mechanism. The information feedback end implements the method, which drives the service singleton to call the set service method to obtain the interaction information according to the service parameters; and feeds back the interaction information that meets the business requirements.

[0058] On the one hand, this invention offers excellent information traceability. Existing information interaction technologies require continuous debugging and tracking to locate the information transmission channel, sometimes involving multiple nodes. If a problem occurs in the information interaction, each node needs to be investigated and repaired, significantly increasing the workload. In contrast, this invention uses a unique method to call links, allowing for direct location of the information transmission channel. When encountering problems in information interaction, even in complex system programs, only the information request layer needs to be located. The information transmission channel can be directly located through the interface link of the information request layer, and troubleshooting and repair can be performed on the three nodes within the information transmission channel. Compared to existing information interaction technologies, this significantly reduces the workload of locating problems.

[0059] On the other hand, this invention offers high information transmission efficiency. Existing information exchange technologies mostly use custom objects or XML for information transmission. Both custom objects and XML involve additional factors during serialization and deserialization, such as the need to implement certain interfaces, and the compiler needing to consider attribute types and structural forms, which can limit interaction efficiency to some extent. In contrast, this invention employs a lightweight data storage structure that only needs to consider the key-value mapping relationship during serialization and deserialization, achieving faster data serialization and deserialization compared to existing information exchange technologies, thereby improving information exchange efficiency.

Claims

1. An information interaction method based on a meta-object invocation mechanism under the QT platform, characterized in that: Includes the following steps: 1) Configure service parameters, service mapping relationships, interface link mapping relationships, and instance mapping relationships; Service parameters are used to filter the interaction information of the request; Instance mapping is used to represent the mapping relationship between various classes and their corresponding singletons; Various types of services are used to call their respective service classes and return the interaction information obtained by the service classes; service mapping relationships are used to represent the mapping relationship between each service class and its corresponding service singleton; each service class is used to obtain the corresponding interaction information based on the service parameters; interface link mapping relationships are used to represent the mapping relationship between each interface link information and the class information and method information used in the corresponding interface link. 2) The information requesting end sends a request message with a set data format through a set sending mechanism; the request message includes interface link information and service parameters; 3) The information processing end receives interface link information and service parameters; based on the interface link information, it obtains the corresponding class information and method information from the interface link mapping relationship; Based on the class information, the corresponding singleton is obtained in the instance mapping relationship; based on the meta-object invocation mechanism, the method corresponding to the method information is called through the singleton, and the service parameters are set to the parameter values ​​of the method; the method corresponding to the method information is defined by macros; 4) In the information feedback end, this method obtains the service singleton of the service class based on the service mapping relationship, and drives the service singleton to call the set service method to obtain the interaction information based on the service parameters; And provide feedback on the interaction information; Service mapping relationships, interface link mapping relationships, and instance mapping relationships are stored using a key-value collection. The key assigns a unique identifier to each interface link, control layer, and service, while the value is the specific value; the corresponding value information is obtained through the key during the information exchange phase.

2. The information interaction method based on the meta-object invocation mechanism under the QT platform according to claim 1, characterized in that: Add a mutex lock when creating a singleton to ensure that only one instance of each class can be generated.

3. The information interaction method based on the meta-object invocation mechanism under the QT platform according to claim 1, characterized in that: The specified data format is a string.

4. The information interaction method based on the meta-object invocation mechanism under the QT platform according to claim 3, characterized in that: Request information in string data format is obtained in the following way: Encapsulate the interface connection information and service parameters into a JsonObject object; convert the JsonObject object into a string.

5. The information interaction method based on the meta-object invocation mechanism under the QT platform according to claim 1, characterized in that: The method corresponding to the method information is defined by Q_INVOKABLE; in step 3), the invokeMethod function is used to implement the singleton invocation of the method corresponding to the method information based on the meta-object invocation mechanism.

6. The information interaction method based on the meta-object invocation mechanism under the QT platform according to any one of claims 1 to 5, characterized in that: The sending mechanism is set to a message queue.

Citation Information

Patent Citations

  • remote procedure calling method based on NETTY

    CN109756461A

  • Optimization method and system for JSON serialization and deserialization

    CN113138755A