[go: up one dir, main page]

CN112988279B - Object processing method and device, electronic equipment and storage medium - Google Patents

Object processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112988279B
CN112988279B CN202110411407.3A CN202110411407A CN112988279B CN 112988279 B CN112988279 B CN 112988279B CN 202110411407 A CN202110411407 A CN 202110411407A CN 112988279 B CN112988279 B CN 112988279B
Authority
CN
China
Prior art keywords
implementation class
extension module
interface
dynamic extension
registration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110411407.3A
Other languages
Chinese (zh)
Other versions
CN112988279A (en
Inventor
郝志刚
王江林
文述生
李宁
肖浩威
马原
徐丹龙
黄海锋
邹盛开
闫志愿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
South Surveying & Mapping Technology Co ltd
Original Assignee
South GNSS Navigation Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by South GNSS Navigation Co Ltd filed Critical South GNSS Navigation Co Ltd
Priority to CN202110411407.3A priority Critical patent/CN112988279B/en
Publication of CN112988279A publication Critical patent/CN112988279A/en
Application granted granted Critical
Publication of CN112988279B publication Critical patent/CN112988279B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44594Unloading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses an object processing method, an object processing device, electronic equipment and a storage medium, which are used for solving the technical problem that in the prior art, an object created through a module is released through other modules in the actual programming process. The method comprises the following steps: when an object creation instruction aiming at a preset registration realization class is received, acquiring a dynamic expansion module corresponding to the registration realization class from a preset expandable object creation system; creating an object of a registration realization class through a dynamic expansion module; when a release instruction for an object is received, a dynamic expansion module corresponding to the object is acquired in an expandable object creation system; the object is released by the dynamic expansion module.

Description

一种对象处理方法、装置、电子设备及存储介质Object processing method, device, electronic device and storage medium

技术领域Technical Field

本发明涉及应用程序开发技术领域,尤其涉及一种对象处理方法、装置、电子设备及存储介质。The present invention relates to the technical field of application development, and in particular to an object processing method, device, electronic device and storage medium.

背景技术Background Art

目前企业级应用系统大多采用三层或者多层应用模式。而大多数企业级应用系统都选择了面向对象的编程技术。所谓“对象”就是一个或一组数据以及处理这些数据的方法和过程的集合。对象的产生有两种基本方式。一种是以原型对象为基础产生新的对象,一种是以类为基础产生新的对象。At present, most enterprise-level application systems adopt three-tier or multi-tier application models. Most enterprise-level application systems choose object-oriented programming technology. The so-called "object" is a collection of one or a group of data and the methods and processes for processing these data. There are two basic ways to generate objects. One is to generate new objects based on prototype objects, and the other is to generate new objects based on classes.

在实际应用中,现有技术可以通过new和delete操作符来实现类对象的创建和释放,为了避免内存的泄露,通常这两个操作符需要成对地使用。In practical applications, the existing technology can use the new and delete operators to create and release class objects. In order to avoid memory leaks, these two operators usually need to be used in pairs.

而在实际编程过程中,经常会出现创建类对象和释放类对象是在不同的模块(动态链接库)中进行,这样很容易出现错误。In the actual programming process, it is often the case that class objects are created and released in different modules (dynamic link libraries), which can easily lead to errors.

发明内容Summary of the invention

本发明提供了一种对象处理方法、装置、电子设备及存储介质,用于解决现有技术通过模块创建的对象在实际编程过程中,存在通过其他模块释放的技术问题。The present invention provides an object processing method, device, electronic device and storage medium, which are used to solve the technical problem that objects created by modules in the prior art are released by other modules during the actual programming process.

本发明提供了一种对象处理方法,包括:The present invention provides an object processing method, comprising:

当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块;When receiving an object creation instruction for a preset registration implementation class, obtaining a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system;

通过所述动态扩展模块创建所述注册实现类的对象;Creating an object of the registration implementation class through the dynamic extension module;

当接收到针对所述对象的释放指令时,在所述可扩展对象创建系统中获取所述对象对应的所述动态扩展模块;When a release instruction for the object is received, acquiring the dynamic extension module corresponding to the object in the extensible object creation system;

通过所述动态扩展模块释放所述对象。The object is released by the dynamic extension module.

可选地,所述当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块的步骤之前,还包括:Optionally, when receiving an object creation instruction for a preset registration implementation class, before the step of acquiring a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system, the method further includes:

创建接口;Create an interface;

向预设的可扩展对象创建系统声明所述接口;Declaring the interface to a preset extensible object creation system;

在所述动态扩展模块中编写已声明的所述接口的实现类;Writing an implementation class of the declared interface in the dynamic extension module;

向所述可扩展对象创建系统注册所述实现类,得到注册实现类。The implementation class is registered with the extensible object creation system to obtain a registered implementation class.

可选地,所述通过所述动态扩展模块创建所述注册实现类的对象的步骤,包括:Optionally, the step of creating an object of the registration implementation class through the dynamic extension module includes:

通过所述动态扩展模块获取所述注册实现类的标识符;Obtaining an identifier of the registration implementation class through the dynamic extension module;

基于所述标识符获取所述注册实现类的构造函数;Obtaining a constructor of the registration implementation class based on the identifier;

采用所述构造函数,创建所述注册实现类的对象。The constructor is used to create an object of the registration implementation class.

可选地,所述通过所述动态扩展模块释放所述对象的步骤,包括:Optionally, the step of releasing the object through the dynamic extension module includes:

通过所述动态扩展模块基于所述标识符,获取所述注册实现类的析构函数;Obtaining a destructor of the registration implementation class based on the identifier through the dynamic extension module;

采用所述析构函数释放所述对象。The object is released using the destructor.

本发明还提供了一种对象处理装置,包括:The present invention also provides an object processing device, comprising:

第一动态扩展模块获取模块,用于当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块;A first dynamic extension module acquisition module is used to, when receiving an object creation instruction for a preset registration implementation class, acquire a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system;

对象创建模块,用于通过所述动态扩展模块创建所述注册实现类的对象;An object creation module, used to create an object of the registration implementation class through the dynamic extension module;

第二动态扩展模块获取模块,用于当接收到针对所述对象的释放指令时,在所述可扩展对象创建系统中获取所述对象对应的所述动态扩展模块;A second dynamic extension module acquisition module is used to acquire the dynamic extension module corresponding to the object in the extensible object creation system when receiving a release instruction for the object;

对象释放模块,用于通过所述动态扩展模块释放所述对象。The object releasing module is used to release the object through the dynamic extension module.

可选地,还包括:Optionally, it also includes:

接口创建模块,用于创建接口;Interface creation module, used to create interfaces;

接口声明模块,用于向预设的可扩展对象创建系统声明所述接口;An interface declaration module, used for declaring the interface to a preset extensible object creation system;

实现类编写模块,用于在所述动态扩展模块中编写已声明的所述接口的实现类;An implementation class writing module, used for writing the implementation class of the declared interface in the dynamic extension module;

实现类注册模块,用于向所述可扩展对象创建系统注册所述实现类,得到注册实现类。The implementation class registration module is used to register the implementation class with the extensible object creation system to obtain a registered implementation class.

可选地,所述对象创建模块,包括:Optionally, the object creation module includes:

标识符获取子模块,用于通过所述动态扩展模块获取所述注册实现类的标识符;An identifier acquisition submodule, used to acquire the identifier of the registration implementation class through the dynamic extension module;

构造函数获取子模块,用于基于所述标识符获取所述注册实现类的构造函数;A constructor acquisition submodule, used for acquiring the constructor of the registration implementation class based on the identifier;

对象创建子模块,用于采用所述构造函数,创建所述注册实现类的对象。The object creation submodule is used to adopt the constructor to create an object of the registration implementation class.

可选地,所述对象释放模块,包括:Optionally, the object releasing module includes:

析构函数获取子模块,用于通过所述动态扩展模块基于所述标识符,获取所述注册实现类的析构函数;A destructor acquisition submodule, used to acquire the destructor of the registered implementation class based on the identifier through the dynamic extension module;

对象释放子模块,用于采用所述析构函数释放所述对象。The object release submodule is used to release the object using the destructor.

本发明还提供了一种电子设备,所述设备包括处理器以及存储器:The present invention also provides an electronic device, the device comprising a processor and a memory:

所述存储器用于存储程序代码,并将所述程序代码传输给所述处理器;The memory is used to store program code and transmit the program code to the processor;

所述处理器用于根据所述程序代码中的指令执行如上任一项所述的对象处理方法。The processor is used to execute any one of the above object processing methods according to the instructions in the program code.

本发明还提供了一种计算机可读存储介质,所述计算机可读存储介质用于存储程序代码,所述程序代码用于执行如上任一项所述的对象处理方法。The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program codes, and the program codes are used to execute the object processing method as described in any one of the above items.

从以上技术方案可以看出,本发明具有以下优点:本发明通过当接收到针对预设注册实现类的对象创建指令时,在预设可扩展对象创建系统中获取注册实现类对应的动态扩展模块;通过动态扩展模块创建注册实现类的对象;当接收到针对对象的释放指令时,在可扩展对象创建系统中获取对象对应的动态扩展模块;通过动态扩展模块释放对象。解决了现有技术通过模块创建的对象在实际编程过程中,存在通过其他模块释放的技术问题。It can be seen from the above technical scheme that the present invention has the following advantages: when receiving an object creation instruction for a preset registration implementation class, the present invention obtains a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system; creates an object of the registration implementation class through the dynamic extension module; when receiving a release instruction for the object, obtains a dynamic extension module corresponding to the object in the extensible object creation system; and releases the object through the dynamic extension module. This solves the technical problem that objects created by modules in the prior art are released through other modules in the actual programming process.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

图1为本发明实施例提供的一种对象处理方法的步骤流程图;FIG1 is a flowchart of a method for processing an object provided by an embodiment of the present invention;

图2为本发明另一实施例提供的一种对象处理方法的步骤流程图;FIG2 is a flowchart of a method for processing an object according to another embodiment of the present invention;

图3为本发明实施例提供的一种对象处理方法的过程示意图;FIG3 is a schematic diagram of a process of an object processing method provided by an embodiment of the present invention;

图4为本发明实施例提供的一种对象处理装置的结构框图。FIG. 4 is a structural block diagram of an object processing device provided by an embodiment of the present invention.

具体实施方式DETAILED DESCRIPTION

本发明实施例提供了一种对象处理方法、装置、电子设备及存储介质,用于解决现有技术通过模块创建的对象在实际编程过程中,存在通过其他模块释放的技术问题。The embodiments of the present invention provide an object processing method, device, electronic device and storage medium, which are used to solve the technical problem that objects created by modules in the prior art are released by other modules during the actual programming process.

为使得本发明的发明目的、特征、优点能够更加的明显和易懂,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,下面所描述的实施例仅仅是本发明一部分实施例,而非全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

请参阅图1,图1为本发明实施例提供的一种对象处理方法的步骤流程图。Please refer to FIG. 1 , which is a flow chart of the steps of an object processing method provided by an embodiment of the present invention.

本发明提供的一种对象处理方法,具体可以包括以下步骤:The object processing method provided by the present invention may specifically include the following steps:

步骤101,当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取注册实现类对应的动态扩展模块;Step 101, when an object creation instruction for a preset registration implementation class is received, a dynamic extension module corresponding to the registration implementation class is obtained in a preset extensible object creation system;

在本发明实施例中,动态扩展模块可以为动态链接库或组件库。In the embodiment of the present invention, the dynamic extension module may be a dynamic link library or a component library.

动态链接库(Dynamic Link Library,DLL)是Windows操作系统中。实现共享函数库概念的一种方式。这些函数的扩展名“.dll”、“.ocx”(包含ActiveX控制的库),或者“.drv”(旧式的系统驱动程序)。动态链接提供了一种方法,是进程可以调用不属于其可执行代码的函数。函数的可执行代码位于一个DLL文件中,该DLL文件包含一个或多个已被翻译、链接并与使用它们的进程分开存储的函数。DLL还有助于共享数据和资源。多个应用程序可以同时访问内存中单个DLL副本的内容。使用动态链接库可以较为容易地将更新应用于各个模块,而不会影响该程序的其他部分。DLL提供了如模块化这样的共享库的作用,模块化允许仅仅更改几个应用程序共享使用的一个DLL中的代码和数据而不需要更改应用程序自身。模块化的另外一个好处是插件的通用接口使用。单个的接口允许旧的模块与新的模块一样能够与以前的应用程序运行时无缝地集成到一起,而不需要对应用程序本身作任何更改。Dynamic Link Library (DLL) is a way to implement the concept of shared function libraries in Windows operating systems. These functions have the extension ".dll", ".ocx" (libraries containing ActiveX controls), or ".drv" (old-style system drivers). Dynamic linking provides a way for a process to call functions that are not part of its executable code. The executable code of a function is located in a DLL file, which contains one or more functions that have been translated, linked, and stored separately from the processes that use them. DLL also helps to share data and resources. Multiple applications can access the contents of a single copy of a DLL in memory at the same time. Using dynamic link libraries, updates can be applied to individual modules more easily without affecting other parts of the program. DLL provides the role of shared libraries such as modularity, which allows only the code and data in a DLL shared by several applications to be changed without changing the application itself. Another benefit of modularity is the use of common interfaces for plug-ins. A single interface allows old modules to be seamlessly integrated with previous application runtimes just like new modules, without making any changes to the application itself.

在本发明实施例中,可以预先构建一个可扩展对象创建系统,该系统中部署有动态链接库。其中,动态链接库可以为一个或多个。In the embodiment of the present invention, an extensible object creation system can be pre-built, in which a dynamic link library is deployed, wherein the dynamic link library can be one or more.

在本发明实施例中,可拓展对象创建系统可以进行插件化、组件化编程。同时可以提供接口的声明、实现类的注册、对象的创建和释放、动态扩展模块的加载与卸载、获取指定接口的所有注册的实现类的注册名字等方法。In the embodiment of the present invention, the extensible object creation system can be plug-in and component-based programming. At the same time, it can provide methods such as interface declaration, implementation class registration, object creation and release, dynamic extension module loading and unloading, and obtaining the registered names of all registered implementation classes of a specified interface.

在实际应用中,当接收到针对预设注册实现类的对象创建指令时,可以在预设的可拓展对象创建系统中获取注册实现类对应的动态扩展模块,以进行对象创建。In actual applications, when an object creation instruction for a preset registration implementation class is received, a dynamic extension module corresponding to the registration implementation class can be obtained in a preset extensible object creation system to perform object creation.

步骤102,通过动态扩展模块创建注册实现类的对象;Step 102, creating an object of the registration implementation class through the dynamic extension module;

在获取到进行对象创建的动态扩展模块后,可以通过可扩展对象创建系统提供的创建对象的方法进行注册实现类的对象创建,然后通过注册实现类对应的接口完成相关方法的调用。其中,注册实现类可以与其接口在同一个动态扩展模块中,也可以不在同一个动态扩展模块中。After obtaining the dynamic extension module for object creation, you can use the object creation method provided by the extensible object creation system to create the object of the registration implementation class, and then complete the call of related methods through the interface corresponding to the registration implementation class. Among them, the registration implementation class and its interface can be in the same dynamic extension module or not.

步骤103,当接收到针对对象的释放指令时,在可扩展对象创建系统中获取对象对应的动态扩展模块;Step 103, when a release instruction for an object is received, a dynamic extension module corresponding to the object is obtained in the extensible object creation system;

步骤104,通过动态扩展模块释放对象。Step 104: Release the object through the dynamic extension module.

在本发明实施例中,在完成了对象创建后,当接收到针对该对象的释放指令时,可以在可扩展对象创建系统中获取注册实现类对应的动态扩展模块,以通过该动态扩展模块释放该对象。In the embodiment of the present invention, after the object creation is completed, when a release instruction for the object is received, the dynamic extension module corresponding to the registered implementation class can be obtained in the extensible object creation system to release the object through the dynamic extension module.

本发明通过在可扩展对象创建系统中获取注册实现类对应的动态扩展模块,以通过该动态扩展模块进行对象创建。同时,根据注册实现类与动态扩展模块的对应关系,可以在需要释放对象时,获取同一个动态扩展模块进行对象释放操作。The present invention obtains the dynamic extension module corresponding to the registered implementation class in the extensible object creation system, so as to create an object through the dynamic extension module. At the same time, according to the corresponding relationship between the registered implementation class and the dynamic extension module, when the object needs to be released, the same dynamic extension module can be obtained to perform the object release operation.

请参阅图2,图2为本发明另一实施例提供的一种对象处理方法的步骤流程图。该方法具体可以包括以下步骤:Please refer to Figure 2, which is a flowchart of a method for processing an object provided by another embodiment of the present invention. The method may specifically include the following steps:

步骤201,创建接口;Step 201, create an interface;

接口,是抽象方法和常量值的定义的集合,从本质上讲,接口是一种特殊的抽象类,这种抽象类中只包含常量和方法的定义,而没有变量和方法的实现。接口一般定义如何使用。包括外部程序如何调用,以及自己的内部程序之间如何调用。An interface is a collection of definitions of abstract methods and constant values. In essence, an interface is a special abstract class that only contains constant and method definitions, but no variable and method implementations. An interface generally defines how to use it, including how external programs call it, and how internal programs call each other.

在本发明实施例中,使用者可以在通用的基础模块/底层模块中编写所需要的接口,例如ICommand类接口。其中,本发明实施例创建的接口需要满足如下要求:所有方法必须是纯虚方法且不包含任何成员变量,接口必须处于某个.h文件当中。In the embodiment of the present invention, the user can write the required interface in the general basic module/bottom layer module, such as the ICommand class interface. Among them, the interface created in the embodiment of the present invention needs to meet the following requirements: all methods must be pure virtual methods and do not contain any member variables, and the interface must be in a .h file.

纯虚方法也叫抽象函数,一般来说它只有函数名、参数和返回值类型,不需要函数体。这意味着它没有函数的实现,需要让派生类去实现。A pure virtual method is also called an abstract function. Generally speaking, it only has a function name, parameters, and return value type, and does not require a function body. This means that it has no function implementation and needs to be implemented by the derived class.

C++中的纯虚方法,一般在函数签名后使用=0作为此类函数的标志。Java、C#等语言中,则直接使用abstract作为关键字修饰这个函数签名,表示这是纯虚方法。In C++, pure virtual methods usually use = 0 after the function signature as a sign of this type of function. In languages such as Java and C#, abstract is directly used as a keyword to modify the function signature, indicating that this is a pure virtual method.

步骤202,向预设的可扩展对象创建系统声明接口;Step 202, declaring an interface to a preset extensible object creation system;

在本发明实施例中,在完成了接口创建后,可以向可扩展对象创建系统声明该接口。In the embodiment of the present invention, after the interface creation is completed, the interface can be declared to the extensible object creation system.

在一个示例中,可通过可扩展对象创建系统提供的声明方法,如EXTENSIBLE_FACTORY_DECLARE进行声明。单个接口只需要声明一次即可。同时,在接口所在模块的任意include接口所在的.h文件的.cpp文件当中通过可扩展对象创建系统提供的声明方法EXTENSIBLE_FACTORY_DEFINE进行定义。In one example, the declaration method provided by the extensible object creation system, such as EXTENSIBLE_FACTORY_DECLARE, can be used for declaration. A single interface only needs to be declared once. At the same time, the definition is performed in any .cpp file of the module where the interface is located, using the declaration method EXTENSIBLE_FACTORY_DEFINE provided by the extensible object creation system, which includes the .h file where the interface is located.

步骤203,在动态扩展模块中编写已声明的接口的实现类;Step 203, writing the implementation class of the declared interface in the dynamic extension module;

类是现实世界或思维世界中的实体在计算机中的反映,它将数据以及这些数据上的操作封装在一起。实现类,用于实现接口的功能。A class is a reflection of an entity in the real world or the mental world in a computer. It encapsulates data and operations on the data. An implementation class is used to implement the functions of an interface.

在本发明实施例中,可以在动态扩展模块中编写该接口的实现类,并实现继承该接口的所有纯虚方法。In the embodiment of the present invention, the implementation class of the interface can be written in the dynamic extension module, and all pure virtual methods inherited from the interface can be implemented.

其中,实现类的技术要求如下:其构造函数必须满足可扩展的对象创建系统的要求,第一个参数的类型必须为const char*,第二个参数的类型必须为const void*,且只能包含着两个参数。Among them, the technical requirements for the implementation class are as follows: its constructor must meet the requirements of the extensible object creation system, the type of the first parameter must be const char*, the type of the second parameter must be const void*, and it can only contain two parameters.

步骤204,向可扩展对象创建系统注册实现类,得到注册实现类;Step 204, registering the implementation class with the extensible object creation system to obtain the registered implementation class;

在完成实现类的编写后,可以在可扩展创建系统的动态扩展模块的实现类的源文件(CPP)中进行实现类的注册。After the implementation class is written, the implementation class can be registered in the source file (CPP) of the implementation class of the dynamic extension module of the extensible creation system.

具体地,可通过可扩展对象创建系统提供的进行注册的方法EXTENSIBLE_FACTORY_REGISTER进行注册,从而得到注册实现类。Specifically, the registration may be performed through the registration method EXTENSIBLE_FACTORY_REGISTER provided by the extensible object creation system, thereby obtaining a registration implementation class.

需要注意的是,具体的实现类只能向其继承的接口进行注册;同一个实现类可以注册多个名字且只需要注册一次即可;同一个接口可以被多个实现类注册。It should be noted that a specific implementation class can only be registered with the interface it inherits; the same implementation class can register multiple names and only needs to be registered once; the same interface can be registered by multiple implementation classes.

步骤205,当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取注册实现类对应的动态扩展模块;Step 205, when receiving an object creation instruction for a preset registration implementation class, obtaining a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system;

在本发明实施例中,在接收到针对预设注册实现类的对象创建指令后,可以通过可扩展对象创建系统提供的方法加载动态扩展模块。In the embodiment of the present invention, after receiving an object creation instruction for a preset registration implementation class, the dynamic extension module can be loaded through a method provided by the extensible object creation system.

在一个示例中,该加载动态扩展模块的方法可以为extensible_factory_load_dlls。In an example, the method for loading the dynamic extension module may be extensible_factory_load_dlls.

步骤206,通过动态扩展模块创建注册实现类的对象;Step 206, creating an object of the registration implementation class through the dynamic extension module;

对象是对客观事物的抽象。是具有类类型的变量。类和对象是面向对象编程技术中的最基本的概念。类是对象的抽象,而对象是类的具体实例。类是一个模板,其描述一类对象的行为和状态,而对象是类的一个示例,有状态和行为。例如,狗是一个类,一条狗是一个对象,它的状态有:颜色、名字、品种;行为有:摇尾巴、叫、吃等。An object is an abstraction of objective things. It is a variable with a class type. Class and object are the most basic concepts in object-oriented programming technology. A class is an abstraction of an object, and an object is a specific instance of a class. A class is a template that describes the behavior and state of a class of objects, while an object is an example of a class with state and behavior. For example, a dog is a class, and a dog is an object. Its states include: color, name, and breed; its behaviors include: wagging its tail, barking, eating, etc.

在本发明实施例中在完成了动态扩展模块的加载操作后,可以通过动态扩展模块创建注册实现类的对象。In the embodiment of the present invention, after the loading operation of the dynamic extension module is completed, an object of the registration implementation class can be created through the dynamic extension module.

具体地,通过可扩展对象创建系统提供的方法extensible_factory_get_xxx进行对象的创建,其中,xxx为接口类的名称。Specifically, the object is created through the method extensible_factory_get_xxx provided by the extensible object creation system, where xxx is the name of the interface class.

在一个示例中,步骤206可以包括以下子步骤:In one example, step 206 may include the following sub-steps:

S61,通过动态扩展模块获取注册实现类的标识符;S61, obtaining an identifier of a registration implementation class through a dynamic extension module;

S62,基于标识符获取注册实现类的构造函数;S62, obtaining a constructor of the registration implementation class based on the identifier;

S63,采用构造函数,创建注册实现类的对象。S63, using the constructor, to create an object of the registration implementation class.

在具体实现中,创建对象的时候可以通过指定的标识符通过全局的Map获取实现类的构造函数,调用构造函数创建接口类的对象。In the specific implementation, when creating an object, you can use the specified identifier to obtain the constructor of the implementation class through the global Map, and call the constructor to create an object of the interface class.

其中,构造函数主要用来在创建对象时初始化对象,即为对象成员变量赋初始值,总与new运算符一起使用在创建对象的语句中。一个类可以有多个构造函数,可根据其参数个数的不同或参数类型的不同来区分。The constructor is mainly used to initialize the object when creating it, that is, to assign initial values to the object member variables. It is always used together with the new operator in the statement to create the object. A class can have multiple constructors, which can be distinguished by the number of parameters or the type of parameters.

步骤207,当接收到针对对象的释放指令时,在可扩展对象创建系统中获取对象对应的动态扩展模块;Step 207, when a release instruction for the object is received, a dynamic extension module corresponding to the object is obtained in the extensible object creation system;

在本发明实施例中,当接收到针对对象的释放指令时,可以通过创建该对象的动态扩展模块,进行对象释放。In the embodiment of the present invention, when a release instruction for an object is received, the object can be released by creating a dynamic extension module of the object.

步骤208,通过动态扩展模块释放对象。Step 208: Release the object through the dynamic extension module.

在本发明实施例中,可通过可扩展对象创建系统提供的释放对象的方法extensible_factory_release_xxx进行对象的释放,其中,xxx为接口类的名称。In the embodiment of the present invention, the object can be released through the object release method extensible_factory_release_xxx provided by the extensible object creation system, where xxx is the name of the interface class.

在一个示例中,步骤208可以包括以下子步骤:In one example, step 208 may include the following sub-steps:

S81,通过动态扩展模块基于标识符,获取注册实现类的析构函数;S81, obtaining the destructor of the registered implementation class based on the identifier through the dynamic extension module;

S82,采用析构函数释放对象。S82, use the destructor to release the object.

在具体实现中,在释放对象的时候,可以通过指定的标识符通过全局的Map获取实现类的析构函数,调用析构函数释放接口类的对象。In the specific implementation, when releasing the object, the destructor of the implementation class can be obtained through the global Map through the specified identifier, and the destructor is called to release the object of the interface class.

其中,析构函数与构造函数相反,当对象结束其生命周期,如对象所在的函数已调用完毕时,可以执行析构函数来释放对象。Among them, the destructor is the opposite of the constructor. When the object ends its life cycle, such as when the function where the object is located has been called, the destructor can be executed to release the object.

需要说明的是,所有的实现类的构造函数和析构函数必须是固定的格式,统一的参数类型、参数顺序和参数个数。It should be noted that the constructors and destructors of all implementation classes must be in a fixed format, with unified parameter types, parameter order, and number of parameters.

本发明通过在可扩展对象创建系统中获取注册实现类对应的动态扩展模块,以通过该动态扩展模块进行对象创建。同时,根据注册实现类与动态扩展模块的对应关系,可以在需要释放对象时,获取同一个动态扩展模块进行对象释放操作。The present invention obtains the dynamic extension module corresponding to the registered implementation class in the extensible object creation system, so as to create an object through the dynamic extension module. At the same time, according to the corresponding relationship between the registered implementation class and the dynamic extension module, when the object needs to be released, the same dynamic extension module can be obtained to perform the object release operation.

为便于理解,以下通过具体示例对本发明实施例进行说明:For ease of understanding, the embodiments of the present invention are described below by using specific examples:

请参阅图3,图3为本发明实施例提供的一种对象处理方法的过程示意图。Please refer to FIG. 3 , which is a schematic diagram of a process of an object processing method provided by an embodiment of the present invention.

如图3所示,可扩展对象创建系统提供了接口的声明、实现类的注册、对象的创建和释放等操作,此外还提供了动态扩展模块的加载与卸载、获取指定接口的所有注册的实现类的注册名字等方法。其实现原理如下:As shown in Figure 3, the extensible object creation system provides operations such as interface declaration, implementation class registration, object creation and release, etc. In addition, it also provides methods such as loading and unloading dynamic extension modules and obtaining the registered names of all registered implementation classes of a specified interface. Its implementation principle is as follows:

1、EXTENSIBLE_FACTORY_DECLARE负责声明对应接口类的工厂方法,声明的方法为extensible_get_xxx等,其中,xxx为接口类名称。1. EXTENSIBLE_FACTORY_DECLARE is responsible for declaring the factory method of the corresponding interface class. The declared method is extensible_get_xxx, etc., where xxx is the name of the interface class.

2、EXTENSIBLE_FACTORY_DEFINE负责对声明的工厂方法进行实现,实现原理是:创建对象的时候通过指定的标识符通过全局的Map获取实现类的构造函数,调用构造函数创建接口类的对象,释放对象的时候通过指定的标识符通过全局的Map获取实现类的析构函数,调用析构函数释放接口类的对象。因此所有实现类的构造函数和析构函数必须是固定的格式,统一的参数类型、参数顺序和参数个数。2. EXTENSIBLE_FACTORY_DEFINE is responsible for implementing the declared factory method. The implementation principle is: when creating an object, the constructor of the implementation class is obtained through the global Map through the specified identifier, and the constructor is called to create an object of the interface class. When releasing the object, the destructor of the implementation class is obtained through the global Map through the specified identifier, and the destructor is called to release the object of the interface class. Therefore, the constructors and destructors of all implementation classes must be in a fixed format, with unified parameter types, parameter order, and number of parameters.

3、EXTENSIBLE_FACTORY_REGISTER负责将实现类的相关信息(类名、构造函数、析构函数等)注册到全局的Map中。3. EXTENSIBLE_FACTORY_REGISTER is responsible for registering the relevant information of the implementation class (class name, constructor, destructor, etc.) into the global Map.

4、应用程序通过可扩展对象创建系统的extensible_factory_get_xxx和extensible_factory_release_xxx方法来创建和释放对象。4. The application creates and releases objects through the extensible_factory_get_xxx and extensible_factory_release_xxx methods of the extensible object creation system.

其使用示例如下:The following are examples of its use:

//Common模块需要定义DLL_API_SPEC=__declspec(dllexport)//Common module needs to define DLL_API_SPEC = __declspec(dllexport)

//Common模块的Command.h//Common module's Command.h

//ICommand即一个接口,所有方法均为纯虚方法,且不包含成员变量//ICommand is an interface, all methods are pure virtual methods, and do not contain member variables

class ICommandclass ICommand

{{

virtual const char*getCommandName()=0;virtual const char*getCommandName()=0;

virtual void setCommandName(const char*cmdName)=0;virtual void setCommandName(const char*cmdName)=0;

};};

#ifndef DLL_API_SPEC#ifndef DLL_API_SPEC

#define DLL_API_SPEC__declspec(dllimport)#define DLL_API_SPEC__declspec(dllimport)

#endif#endif

EXTENSIBLE_FACTORY_DECLARE(ICommand,DLL_API_SPEC);EXTENSIBLE_FACTORY_DECLARE(ICommand,DLL_API_SPEC);

//Common模块的Command.cpp//Common module Command.cpp

#include“Command.h”#include "Command.h"

EXTENSIBLE_FACTORY_DEFINE(ICommand);EXTENSIBLE_FACTORY_DEFINE(ICommand);

//组件模块CommandSpectial的CommandImp.cpp//CommandImp.cpp of the component module CommandSpectial

class Command1class Command1

{{

//构造函数必须是下面的形式,参数类型和个数固定//The constructor must be in the following form, with fixed parameter types and numbers

Command1(const char*csaParam,const void*binParam)Command1(const char*csaParam,const void*binParam)

{{

}}

const char*getCommandName()const char*getCommandName()

{{

return 0;return 0;

}}

void setCommandName(const char*cmdName)void setCommandName(const char*cmdName)

{{

}}

};};

EXTENSIBLE_FACTORY_REGISTER(ICommand,Command1,“cmd1”,“命令1”);EXTENSIBLE_FACTORY_REGISTER(ICommand,Command1,"cmd1","Command1");

class Command2class Command2

{{

//构造函数必须是下面的形式,参数类型和个数固定//The constructor must be in the following form, with fixed parameter types and numbers

Command2(const char*csaParam,const void*binParam)Command2(const char*csaParam,const void*binParam)

{{

}}

const char*getCommandName()const char*getCommandName()

{{

return 0;return 0;

}}

void setCommandName(const char*cmdName)void setCommandName(const char*cmdName)

{{

}}

};};

EXTENSIBLE_FACTORY_REGISTER(ICommand,Command2,“cmd2”,“命令2”);EXTENSIBLE_FACTORY_REGISTER(ICommand,Command2,"cmd2","Command2");

//对ICommand接口的使用//Use of ICommand interface

#include“Command.h”#include "Command.h"

//先加载命令所在组件//First load the component where the command is located

extensible_factory_load_dlls(“CommandSpectial”);extensible_factory_load_dlls("CommandSpectial");

//通过可扩展工厂创建对应的类对象//Create the corresponding class object through the extensible factory

ICommand*command1=extensible_factory_get_ICommand(“cmd1”,0);ICommand*command1=extensible_factory_get_ICommand("cmd1",0);

//通过可扩展工厂释放对应的类对象//Release the corresponding class object through the extensible factory

extensible_factory_release_ICommand(command1);extensible_factory_release_ICommand(command1);

ICommand*command2=extensible_factory_get_ICommand(“cmd2”,0);ICommand*command2=extensible_factory_get_ICommand("cmd2",0);

extensible_factory_release_ICommand(command2);extensible_factory_release_ICommand(command2);

请参阅图4,图4为本发明实施例提供的一种对象处理装置的结构框图。Please refer to FIG. 4 , which is a structural block diagram of an object processing device provided by an embodiment of the present invention.

本发明实施例提供的一种对象处理装置,包括:An embodiment of the present invention provides an object processing device, comprising:

第一动态扩展模块获取模块401,用于当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取注册实现类对应的动态扩展模块;A first dynamic extension module acquisition module 401 is used to acquire a dynamic extension module corresponding to a registration implementation class in a preset extensible object creation system when receiving an object creation instruction for a preset registration implementation class;

对象创建模块402,用于通过动态扩展模块创建注册实现类的对象;The object creation module 402 is used to create an object of the registration implementation class through the dynamic extension module;

第二动态扩展模块获取模块403,用于当接收到针对对象的释放指令时,在可扩展对象创建系统中获取对象对应的动态扩展模块;A second dynamic extension module acquisition module 403 is used to acquire the dynamic extension module corresponding to the object in the extensible object creation system when receiving a release instruction for the object;

对象释放模块404,用于通过动态扩展模块释放对象。The object release module 404 is used to release the object through the dynamic extension module.

在本发明实施例中,还包括:In an embodiment of the present invention, it also includes:

接口创建模块,用于创建接口;Interface creation module, used to create interfaces;

接口声明模块,用于向预设的可扩展对象创建系统声明接口;An interface declaration module, used to declare an interface to a preset extensible object creation system;

实现类编写模块,用于在动态扩展模块中编写已声明的接口的实现类;The implementation class writing module is used to write the implementation class of the declared interface in the dynamic extension module;

实现类注册模块,用于向可扩展对象创建系统注册实现类,得到注册实现类。The implementation class registration module is used to register the implementation class with the extensible object creation system to obtain the registered implementation class.

在本发明实施例中,对象创建模块402,包括:In the embodiment of the present invention, the object creation module 402 includes:

标识符获取子模块,用于通过动态扩展模块获取注册实现类的标识符;The identifier acquisition submodule is used to obtain the identifier of the registered implementation class through the dynamic extension module;

构造函数获取子模块,用于基于标识符获取注册实现类的构造函数;The constructor acquisition submodule is used to obtain the constructor of the registered implementation class based on the identifier;

对象创建子模块,用于采用构造函数,创建注册实现类的对象。The object creation submodule is used to create objects of the registered implementation class using the constructor.

在本发明实施例中,对象释放模块404,包括:In the embodiment of the present invention, the object release module 404 includes:

析构函数获取子模块,用于通过动态扩展模块基于标识符,获取注册实现类的析构函数;The destructor acquisition submodule is used to obtain the destructor of the registered implementation class based on the identifier through the dynamic extension module;

对象释放子模块,用于采用析构函数释放对象。The object release submodule is used to release objects using destructors.

本发明实施例还提供了一种电子设备,设备包括处理器以及存储器:An embodiment of the present invention further provides an electronic device, the device comprising a processor and a memory:

存储器用于存储程序代码,并将程序代码传输给处理器;The memory is used to store program codes and transmit the program codes to the processor;

处理器用于根据程序代码中的指令执行本发明任一实施例的对象处理方法。The processor is used to execute the object processing method of any embodiment of the present invention according to the instructions in the program code.

本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质用于存储程序代码,程序代码用于执行本发明任一实施例的对象处理方法。An embodiment of the present invention further provides a computer-readable storage medium, which is used to store program codes, and the program codes are used to execute the object processing method of any embodiment of the present invention.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

本领域内的技术人员应明白,本发明实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

本发明实施例是参照根据本发明实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The embodiments of the present invention are described with reference to the flowcharts and/or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and/or box in the flowchart and/or block diagram, as well as the combination of the processes and/or boxes in the flowchart and/or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate a device for implementing the functions specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

尽管已描述了本发明实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明实施例范围的所有变更和修改。Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

以上所述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (8)

1.一种对象处理方法,其特征在于,包括:1. An object processing method, comprising: 当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块;其中,动态扩展模块为动态链接库或组件库,其中,所述可扩展对象创建系统能够进行插件化、组件化编程;同时能够提供接口的声明、实现类的注册、对象的创建和释放、动态扩展模块的加载与卸载、获取指定接口的所有注册的实现类的注册名字的方法;When an object creation instruction for a preset registered implementation class is received, a dynamic extension module corresponding to the registered implementation class is obtained in a preset extensible object creation system; wherein the dynamic extension module is a dynamic link library or a component library, wherein the extensible object creation system can perform plug-in and component programming; and can also provide methods for interface declaration, implementation class registration, object creation and release, dynamic extension module loading and unloading, and obtaining the registered names of all registered implementation classes of a specified interface; 通过所述动态扩展模块创建所述注册实现类的对象,包括:Creating an object of the registration implementation class through the dynamic extension module includes: 采用构造函数,创建所述注册实现类的对象;Using a constructor, create an object of the registration implementation class; 其中,构造函数必须满足可扩展的对象创建系统的要求,第一个参数的类型必须为const char*,第二个参数的类型必须为const void*,且只能包含这两个参数;The constructor must meet the requirements of the extensible object creation system. The type of the first parameter must be const char*, the type of the second parameter must be const void*, and it can only contain these two parameters. 在获取到进行对象创建的动态扩展模块后,可以通过可扩展对象创建系统提供的创建对象的方法进行注册实现类的对象创建,然后通过注册实现类对应的接口完成相关方法的调用;其中,注册实现类与其接口在同一个动态扩展模块中;当接收到针对所述对象的释放指令时,在所述可扩展对象创建系统中获取所述对象对应的所述动态扩展模块;After obtaining the dynamic extension module for object creation, the object of the registration implementation class can be created through the object creation method provided by the extensible object creation system, and then the relevant method is called through the interface corresponding to the registration implementation class; wherein the registration implementation class and its interface are in the same dynamic extension module; when a release instruction for the object is received, the dynamic extension module corresponding to the object is obtained in the extensible object creation system; 通过所述动态扩展模块释放所述对象;Releasing the object through the dynamic extension module; 其中,所述当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块的步骤之前,还包括:Wherein, when receiving an object creation instruction for a preset registration implementation class, before the step of acquiring a dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system, the method further includes: 创建接口,其中,所述接口的所有方法必须是纯虚方法且不包含任何成员变量,所述接口必须处于.h文件当中;Create an interface, where all methods of the interface must be pure virtual methods and do not contain any member variables, and the interface must be in a .h file; 向预设的可扩展对象创建系统声明所述接口;Declaring the interface to a preset extensible object creation system; 在所述动态扩展模块中编写已声明的所述接口的实现类,其中,所述实现类只能向其继承的接口进行注册;Writing an implementation class of the declared interface in the dynamic extension module, wherein the implementation class can only be registered with the interface it inherits; 向所述可扩展对象创建系统注册所述实现类,得到注册实现类。The implementation class is registered with the extensible object creation system to obtain a registered implementation class. 2.根据权利要求1所述的方法,其特征在于,所述通过所述动态扩展模块创建所述注册实现类的对象的步骤,包括:2. The method according to claim 1, characterized in that the step of creating an object of the registration implementation class through the dynamic extension module comprises: 通过所述动态扩展模块获取所述注册实现类的标识符;Obtaining an identifier of the registration implementation class through the dynamic extension module; 基于所述标识符获取所述注册实现类的构造函数。A constructor of the registration implementation class is obtained based on the identifier. 3.根据权利要求2所述的方法,其特征在于,所述通过所述动态扩展模块释放所述对象的步骤,包括:3. The method according to claim 2, characterized in that the step of releasing the object through the dynamic extension module comprises: 通过所述动态扩展模块基于所述标识符,获取所述注册实现类的析构函数;Obtaining a destructor of the registration implementation class based on the identifier through the dynamic extension module; 采用所述析构函数释放所述对象。The object is released using the destructor. 4.一种对象处理装置,其特征在于,包括:4. An object processing device, comprising: 第一动态扩展模块获取模块,用于当接收到针对预设注册实现类的对象创建指令时,在预设的可扩展对象创建系统中获取所述注册实现类对应的动态扩展模块;其中,动态扩展模块为动态链接库或组件库,其中,所述可扩展对象创建系统能够进行插件化、组件化编程;同时能够提供接口的声明、实现类的注册、对象的创建和释放、动态扩展模块的加载与卸载、获取指定接口的所有注册的实现类的注册名字的方法;A first dynamic extension module acquisition module is used to, when receiving an object creation instruction for a preset registration implementation class, acquire the dynamic extension module corresponding to the registration implementation class in a preset extensible object creation system; wherein the dynamic extension module is a dynamic link library or a component library, wherein the extensible object creation system can perform plug-in and component programming; and can also provide methods for interface declaration, implementation class registration, object creation and release, dynamic extension module loading and unloading, and acquisition of the registered names of all registered implementation classes of a specified interface; 对象创建模块,用于通过所述动态扩展模块创建所述注册实现类的对象,包括:An object creation module, used to create an object of the registration implementation class through the dynamic extension module, including: 采用构造函数,创建所述注册实现类的对象;Using a constructor, create an object of the registration implementation class; 其中,构造函数必须满足可扩展的对象创建系统的要求,第一个参数的类型必须为const char*,第二个参数的类型必须为const void*,且只能包含这两个参数;The constructor must meet the requirements of the extensible object creation system. The type of the first parameter must be const char*, the type of the second parameter must be const void*, and it can only contain these two parameters. 在获取到进行对象创建的动态扩展模块后,可以通过可扩展对象创建系统提供的创建对象的方法进行注册实现类的对象创建,然后通过注册实现类对应的接口完成相关方法的调用;其中,注册实现类与其接口在同一个动态扩展模块中;After obtaining the dynamic extension module for object creation, the object creation method provided by the extensible object creation system can be used to create the object of the registration implementation class, and then the corresponding interface of the registration implementation class is used to complete the call of the relevant method; wherein, the registration implementation class and its interface are in the same dynamic extension module; 第二动态扩展模块获取模块,用于当接收到针对所述对象的释放指令时,在所述可扩展对象创建系统中获取所述对象对应的所述动态扩展模块;A second dynamic extension module acquisition module is used to acquire the dynamic extension module corresponding to the object in the extensible object creation system when receiving a release instruction for the object; 对象释放模块,用于通过所述动态扩展模块释放所述对象;An object release module, used for releasing the object through the dynamic extension module; 其中,还包括:Among them, it also includes: 接口创建模块,用于创建接口,其中,所述接口的所有方法必须是纯虚方法且不包含任何成员变量,所述接口必须处于.h文件当中;An interface creation module, used to create an interface, wherein all methods of the interface must be pure virtual methods and do not contain any member variables, and the interface must be in a .h file; 接口声明模块,用于向预设的可扩展对象创建系统声明所述接口;An interface declaration module, used for declaring the interface to a preset extensible object creation system; 实现类编写模块,用于在所述动态扩展模块中编写已声明的所述接口的实现类,其中,所述实现类只能向其继承的接口进行注册;An implementation class writing module, used for writing the implementation class of the declared interface in the dynamic extension module, wherein the implementation class can only be registered with the interface it inherits; 实现类注册模块,用于向所述可扩展对象创建系统注册所述实现类,得到注册实现类。The implementation class registration module is used to register the implementation class with the extensible object creation system to obtain a registered implementation class. 5.根据权利要求4所述的装置,其特征在于,所述对象创建模块,包括:5. The device according to claim 4, characterized in that the object creation module comprises: 标识符获取子模块,用于通过所述动态扩展模块获取所述注册实现类的标识符;An identifier acquisition submodule, used to acquire the identifier of the registration implementation class through the dynamic extension module; 构造函数获取子模块,用于基于所述标识符获取所述注册实现类的构造函数。The constructor acquisition submodule is used to acquire the constructor of the registration implementation class based on the identifier. 6.根据权利要求5所述的装置,其特征在于,所述对象释放模块,包括:6. The device according to claim 5, characterized in that the object release module comprises: 析构函数获取子模块,用于通过所述动态扩展模块基于所述标识符,获取所述注册实现类的析构函数;A destructor acquisition submodule, used to acquire the destructor of the registered implementation class based on the identifier through the dynamic extension module; 对象释放子模块,用于采用所述析构函数释放所述对象。The object release submodule is used to release the object using the destructor. 7.一种电子设备,其特征在于,所述设备包括处理器以及存储器:7. An electronic device, characterized in that the device comprises a processor and a memory: 所述存储器用于存储程序代码,并将所述程序代码传输给所述处理器;The memory is used to store program code and transmit the program code to the processor; 所述处理器用于根据所述程序代码中的指令执行权利要求1-3任一项所述的对象处理方法。The processor is used to execute the object processing method according to any one of claims 1 to 3 according to the instructions in the program code. 8.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储程序代码,所述程序代码用于执行权利要求1-3任一项所述的对象处理方法。8. A computer-readable storage medium, characterized in that the computer-readable storage medium is used to store program codes, and the program codes are used to execute the object processing method according to any one of claims 1 to 3.
CN202110411407.3A 2021-04-16 2021-04-16 Object processing method and device, electronic equipment and storage medium Active CN112988279B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110411407.3A CN112988279B (en) 2021-04-16 2021-04-16 Object processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110411407.3A CN112988279B (en) 2021-04-16 2021-04-16 Object processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112988279A CN112988279A (en) 2021-06-18
CN112988279B true CN112988279B (en) 2024-08-20

Family

ID=76340818

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110411407.3A Active CN112988279B (en) 2021-04-16 2021-04-16 Object processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112988279B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568603B (en) * 2021-09-23 2022-02-15 广州中望龙腾软件股份有限公司 Component object creating and interface method calling method, terminal and storage device
CN116700834B (en) * 2023-08-07 2023-10-24 天津华来科技股份有限公司 App modularized loading method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073520A (en) * 2010-12-30 2011-05-25 中国民航信息网络股份有限公司 Dynamic management system and method for C++ application program version
CN104391745A (en) * 2014-10-13 2015-03-04 浪潮通用软件有限公司 Extensible object life cycle management method

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0992898A1 (en) * 1998-09-21 2000-04-12 Hewlett-Packard Company Using a namespace extension to selectively display files read from a computer readable drive
US7305671B2 (en) * 2002-03-22 2007-12-04 Sun Microsystems, Inc. Conversion of an object model to a source file generation model
US20060036990A1 (en) * 2004-08-16 2006-02-16 Lockheed Martin Corporation Tool comprising systems engineering environment for meeting task requirements
US8904365B2 (en) * 2009-08-28 2014-12-02 Adobe Systems Incorporated Dynamic media content instantiation framework
CN105260177A (en) * 2015-09-21 2016-01-20 广东大工数值仿真研究院有限公司 SiPESC platform based Python extension module development method
CN108845837B (en) * 2018-07-09 2021-05-28 武汉斗鱼网络科技有限公司 A method and electronic device for detecting the operating mode of a windows system
CN111209122B (en) * 2019-12-24 2024-06-11 广州华多网络科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN112311773B (en) * 2020-10-15 2021-07-06 上海交通大学 Implementation method for intelligent automobile sensor interface system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073520A (en) * 2010-12-30 2011-05-25 中国民航信息网络股份有限公司 Dynamic management system and method for C++ application program version
CN104391745A (en) * 2014-10-13 2015-03-04 浪潮通用软件有限公司 Extensible object life cycle management method

Also Published As

Publication number Publication date
CN112988279A (en) 2021-06-18

Similar Documents

Publication Publication Date Title
US9891900B2 (en) Generation of specialized methods based on generic methods and type parameterizations
US7131110B2 (en) Method and apparatus for generating a code bridge
CN109299587A (en) Algorithm protection method, device, equipment and storage medium based on go language
US20090307669A1 (en) Memory management for closures
US20080005728A1 (en) Methods, systems, and computer program products for enabling cross language access to an addressable entity in an execution environment
US20080005727A1 (en) Methods, systems, and computer program products for enabling cross language access to an addressable entity
CN112988279B (en) Object processing method and device, electronic equipment and storage medium
CN114588638A (en) Game development method and program development device based on Lua language
CN116719531B (en) Object conversion method, system and medium based on runtime bytecode editing
US20110321009A1 (en) Implementing encryption via aspect oriented programming
CN113850037A (en) DPI and UCLI based dynamic storage method, system, equipment and storage medium
CN117369861A (en) Thread management policy configuration method and related device for application program
Cleeland et al. External polymorphism
CN117251234B (en) Function calling method and device based on patches
CN117891438A (en) A method for implementing AUTOSAR toolbox function library
CN117707540A (en) Development loading method and device for decoupling of internal modules of embedded software
CN118193071A (en) Hardware chip access method, device, equipment and medium
CN118012400A (en) Method set acquisition method and device for program
CN114996128A (en) Script processing method, device and equipment based on ASM framework and storage medium
HK1229917B (en) Metadata-driven dynamic specialization
HK1229917A1 (en) Metadata-driven dynamic specialization

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20241204

Address after: 510000 Si Cheng Road, Tianhe District, Guangzhou, Guangdong Province, No. 39

Patentee after: SOUTH SURVEYING & MAPPING TECHNOLOGY CO.,LTD.

Country or region after: China

Address before: 510000 Tianhe District District, Guangzhou, Guangdong, 39 Tianhe District 4 Building A area, 5 floor, A area, 6 floor A area

Patentee before: GUANGZHOU SOUTH SATELLITE NAVIGATION INSTRUMENT Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right