WO2018121698A1 - 基于c++语言的远程函数调用方法、通信装置 - Google Patents
基于c++语言的远程函数调用方法、通信装置 Download PDFInfo
- Publication number
- WO2018121698A1 WO2018121698A1 PCT/CN2017/119576 CN2017119576W WO2018121698A1 WO 2018121698 A1 WO2018121698 A1 WO 2018121698A1 CN 2017119576 W CN2017119576 W CN 2017119576W WO 2018121698 A1 WO2018121698 A1 WO 2018121698A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- function
- string
- class
- name
- remote
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
- G06F9/548—Object oriented; Remote method invocation [RMI]
Definitions
- the invention relates to the field of remote data processing technology, in particular to a remote function calling method based on C++ language and a communication device.
- Java is a cross-platform programming language.
- the Java reflection mechanism is in the running state. For any class, you can know all the properties and methods of the class; for any object, you can call any of its methods and properties; this dynamically obtained information and dynamic calls
- the function of the object's method is called the reflection mechanism of the Java language.
- the class name and the pointer of the class generation object method, the string that constitutes the class name are stored in the hash table, and the pointer of the corresponding method is obtained by searching the string, and the object can be generated by execution, thereby implementing the string. To generate the corresponding object. This is a good application of the reflection mechanism and is very versatile.
- SDK Software Development Kit
- the embodiment of the invention provides a remote function calling method based on C++ language.
- a brief summary is given below. This generalization is not a general comment, nor is it intended to identify key/critical constituent elements or to describe the scope of protection of these embodiments. Its sole purpose is to present some concepts in a simplified form as a prelude to the following detailed description.
- An object of the present invention is to provide a remote function calling method based on the C++ language.
- the C++ language-based remote function calling method includes: receiving a function call instruction; converting a function called by the function call into a string of a set format; and transmitting the string of the set format to Remote server.
- the string of the set format is used by the remote server to call a local function.
- the information required for the function call includes the function name, the associated class name.
- the function name is used by the remote server to obtain a function address, and the related class name is used by the remote server to create a class instance.
- converting the information required by the function call into a string of the set format includes: creating a connection instance to the remote server; creating a proxy object of a particular class associated with the connection instance; calling a function; The class name of the specific class and the function name of the function are data-packed and converted into a string of a format. Wherein the particular class is associated with the function.
- the C++ language-based remote function invocation method includes: receiving a string of a format format sent by a remote client; parsing the string to obtain information required for a function call; and calling a local function.
- the function call required information includes a function name and an associated class name; wherein the function name is used to obtain a function address, and the related class name is used to create a class instance.
- the function call required information includes a function name and an associated class name, and a related parameter; the calling the local function includes: creating a class instance according to the related class name; The function name, using the class instance to call the local function and passing the related parameters.
- Another object of the present invention is to provide a communication device.
- the communication device includes an information transceiving unit and a central processing unit, wherein the central processing unit includes a first unit that receives a function call instruction, and converts information required for the function call into a setting. A second unit of the formatted string; the set formatted string is transmitted to the remote server via the information transceiving unit.
- the function call required information includes a function name and an associated class name, the related class name being used by the remote server to create a class instance, the function name being the remote service The end is used to get the function address.
- the second unit includes a first subunit that creates a connection instance to the remote server, a second subunit that creates a proxy object of a particular class associated with the connection instance, and, invokes The function converts the class name of the specific class and the function name of the function into a third subunit of the string of the format. Wherein the particular class is associated with the function.
- the function call required information includes a function name and an associated class name, and further includes related parameters;
- the second unit includes a first subunit that creates a connection instance to the remote server, and creates Correlating a second subunit of the proxy object of the specific class of the connection instance, and calling a function and converting the class name of the specific class, the function name of the function, and the related parameter into a format The fourth subunit of the string. Wherein the particular class is associated with the function.
- the communication device includes an information transceiving unit and a central processing unit, wherein the information transceiving unit is configured to receive a string of a format format sent by a remote client; the central processing unit includes The fourth unit that parses the string to obtain the information needed for the function call, and calls the fifth unit of the local function.
- the information required for the function call includes the function name and associated class name.
- the function name is used to obtain a function address, and the related class name is used to create a class instance.
- the function call required information includes a function name and an associated class name, and a related parameter;
- the fifth unit includes a fifth subunit that creates a class instance according to the class name, and Based on the function name, the local function is invoked with the class instance and the seventh sub-unit of the related parameter is passed.
- the technical solution provided by the above embodiment can be used to convert the behavior of the user calling the function on the client side into the behavior of sending the character string containing the function call information to the remote server.
- the server can obtain information about the function call and call the local function, so that the client can remotely call the function based on the C++ language.
- FIG. 1 is a flow chart showing a method of a C++ language-based remote function call according to an exemplary embodiment
- FIG. 2 is a flow diagram showing a method of a C++ language-based remote function call according to another exemplary embodiment
- 3a and 3b are schematic flowcharts of a method for remote function calling based on C++ language according to an application embodiment
- FIG. 4 is a block diagram of a communication device according to an exemplary embodiment.
- FIG. 5 is a block diagram of a communication device, according to another exemplary embodiment.
- relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, and do not require or imply any actual relationship between the entities or operations or order.
- the terms “comprises” or “comprising” or “comprising” or any other variations are intended to encompass a non-exclusive inclusion, such that a process, method, or device that includes a plurality of elements includes not only those elements but also other items not specifically listed. Elements, or elements that are inherent to such a process, method, or device. An element that is defined by the phrase “comprising a " does not exclude the presence of additional equivalent elements in the process, method, or device that comprises the element.
- Figure 1 shows a schematic flow of a remote function call based on the C++ language.
- the method of the remote function call includes: receiving a function call instruction (step S11), converting the information required for the function call into a string of a set format (S12), and transmitting the character of the set format String to the remote server (S13).
- the string of the set format is used by the remote server to call a local function.
- the schematic flow provided by the embodiment can be used to convert the function call behavior into a behavior of sending a string to the remote server.
- the server can obtain information about the function call and call the local function, so that the client can remotely call the function based on the C++ language.
- the information required for the function call includes the function name and associated class name.
- the particular class is associated with the function.
- the server can obtain the function name and related class name, and then can create a class instance, get the function address and call the local function, so that the client can remotely call the function based on the C++ language.
- the information required for the function call includes the function name and associated class name, as well as related parameters.
- the particular class is associated with the function.
- the method further includes: receiving a function call result sent by the remote server.
- Figure 2 shows an illustrative flow of another remote function call based on the C++ language.
- the remote function call method includes: receiving a string of a format format sent by a remote client (step S21), parsing the string to obtain information required for a function call (step S22), The local function is called (step S23).
- the information required by the function call includes a function name and an associated class name, wherein the function name is used to obtain a function address, and the associated class name is used to create a class instance.
- the calling the local function includes: calling the local function with the class instance according to the function name.
- the function call required information includes a function name and associated class name, and also includes related parameters that are used for function calls.
- the calling the local function includes: calling the local function and transmitting the related parameter by using the class instance according to the function name.
- the method further includes: sending a function call result to the remote client.
- the user's host is connected to the robot server through the network as a client.
- the user writes the function code that needs to be implemented on the host using the provided SDK, for example, controlling the robot to advance.
- the partial pseudo code of the function call is shown in Table 1.
- the SDK translates the calling process of the forward function forward() into the behavior of sending a string to the robot server.
- the schematic flow is shown in Figure 3a.
- Step S311 receiving a call instruction of the forward function forward().
- Step S312 creating a connection instance broker to the robot server.
- Step S313 creating an action class proxy object motionProxy associated with the connection instance.
- step S314 the forward function proxy.forward() is called.
- controlling the advancement of the robot is an action of controlling the robot to make advancement, and belongs to the control robot to make an action, so an action class proxy object needs to be created when creating the proxy object. That is, the class of the proxy object is related to the function being called. In other scenarios, such as controlling the robot for speech recognition or image recognition, when a speech recognition function or an image recognition function is invoked, the class of the proxy object will change, for example, to identify a class proxy object, rather than an action class proxy object.
- Step S315 calling the general function Callfunction in C++, the data of the class name "motionProxy”, the function name "forward()", and the parameter list are packaged and converted into a string of a set format.
- Step S316 sending a string of the set format to the robot server.
- Step S317 waiting for the robot server to return the result of the function call.
- Step S321 receiving a string of a format format sent by the client host
- step S322 the parsing string obtains the function name "forward()", the class name "motionProxy”, and the parameter list.
- Step S323 creating a class instance according to the class name "motionProxy”.
- Step S324 according to the function name "forward()", the local function is called by the class instance and the parameter list is passed.
- the optional pseudo-code for partial reference includes "instance->forward(params)".
- Step S325 the function call result is sent to the client host.
- Figure 4 shows a schematic structure of an alternative communication device.
- the communication device comprises an information transceiving unit S1 and a central processing unit S2, the central processing unit S2 comprising a first unit S201 and a second unit S202.
- the first unit S201 is configured to receive a function call instruction.
- the second unit S202 is configured to convert the information required for the function call into a string of a set format.
- the information transceiving unit S1 transmits the character string of the set format to the remote server.
- the information required for the function call includes the function name and associated class name.
- the function name is used by the remote server to obtain a function address, and the related class name is used by the remote server to create a class instance.
- the second unit S202 includes a first subunit that creates a connection instance to the remote server, a second subunit that creates a proxy object of a particular class associated with the connection instance, and a function that calls the function and classifies the particular class
- the name and the function name of the function are packaged into a third sub-unit of the string of the format. Wherein the specific class is associated with the local function.
- the information required by the function call includes a function name and an associated class name, and includes related parameters.
- the second unit S202 includes a first subunit that creates a connection instance to the remote server, a second subunit that creates a proxy object of a particular class associated with the connection instance, and a function that calls the function and classifies the particular class.
- the name, the function name of the function, and the related parameter are data-packed into a fourth sub-unit of the string of the set format.
- the information transceiving unit is further configured to: after sending the string of the set format to the remote server, receive a function call result sent by the remote server.
- Figure 5 shows a schematic structure of another alternative communication device.
- the communication device includes an information transceiving unit S3 and a central processing unit S4.
- the information transceiving unit S3 is configured to receive a character string of a set format transmitted by the remote client;
- the central processing unit S4 includes a fourth unit S401 and a fifth unit S402.
- the fourth unit S401 is configured to parse the string to obtain information required for the function call, and the fifth unit S402 is configured to call the local function.
- the information required for the function call includes the function name and associated class name.
- the function name is used to obtain a function address, and the related class name is used to create a class instance.
- the fifth unit S402 includes a fifth subunit that creates a class instance according to the associated class name, and invokes a sixth subunit of the local function with the class instance according to the function name.
- the function call required information includes a function name and an associated class name, and a related parameter;
- the fifth unit includes a fifth subunit that creates a class instance according to the related class name. And, according to the function name, invoke the local function with the class instance and pass the seventh subunit of the related parameter.
- the information transceiving unit S3 is further configured to send a function call result to the remote client.
- non-transitory computer readable storage medium comprising instructions, such as a memory comprising instructions executable by a processor to perform the methods described above.
- the above non-transitory computer readable storage medium may be a read only memory (ROM), a random access memory (RAM), a magnetic tape, an optical storage device, or the like.
- the disclosed methods, products may be implemented in other manners.
- the device embodiments described above are merely illustrative.
- the division of the unit is only a logical function division.
- there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
- the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mobile Radio Communication Systems (AREA)
- Telephonic Communication Services (AREA)
Abstract
一种基于C++语言的远程函数调用方法和一种通信装置,所述方法包括:接收函数调用指令(S11);将函数调用所需信息转化为设定格式的字符串(S12);发送所述设定格式的字符串到远程服务端(S13)。用户在客户端基于C++语言调用函数时,采用上述方法能够将用户在客户端调用函数的行为转化为向远程服务端发送包含函数调用信息的字符串的行为。通过客户端发送的字符串,服务端能够获得函数调用的相关信息并调用本地函数,从而使客户端能够基于C++语言进行远程调用函数。
Description
本发明涉及远程数据处理技术领域,特别涉及一种基于C++语言的远程函数调用方法及一种通信装置。
爪哇(Java)是一种跨平台的程序设计语言。Java反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意一个方法和属性;这种动态获取的信息以及动态调用对象的方法的功能称为Java语言的反射机制。在Java语言里,将类名和类生成对象方法的指针,组成类名的字符串,存放在哈希表里,通过查找字符串得到对应方法的指针,执行就可以生成对象,从而实现通过字符串来生成对应的对象。这是反射机制很好的应用且用途很广。
现在越来越多的产品需求是提供软件开发工具包(SDK,Software Development Kit)给用户进行二次开发,用户在本地主机编写功能代码,远程连接到远端设备并在远端执行对应的功能。但在C++语言中,在远程函数调用场景中,还没有具体的方法通过传输字符串产生函数调用的功能。
发明内容
本发明实施例提供了一种基于C++语言的远程函数调用方法。为了对披露的实施例的一些方面有一个基本的理解,下面给出了简单的概括。该概括部分不是泛泛评述,也不是要确定关键/重要组成元素或描绘这些实施例的保护范围。其唯一目的是用简单的形式呈现一些概念,以此作为后面的详细说明的序言。
本发明的一个目的在于提供一种基于C++语言的远程函数调用方法。
在一些示意性实施例中,所述基于C++语言的远程函数调用方法包括:接收函数调用指令;将函数调用所需信息转化为设定格式的字符串;发送 所述设定格式的字符串到远程服务端。其中,所述设定格式的字符串被远程服务端用于调用本地函数。
在一些可选实施例中,所述函数调用所需信息包括函数名、相关的类名。其中,所述函数名被所述远程服务端用于获取函数地址,所述相关的类名被所述远程服务端用于创建类实例。
在一些可选实施例中,将函数调用所需信息转化为设定格式的字符串包括:创建到所述远程服务端的连接实例;创建关联所述连接实例的特定类的代理对象;调用函数;将所述特定类的类名和所述函数的函数名进行数据打包,转化为设定格式的字符串。其中,所述特定类与所述函数相关联。
在一些可选实施例中,所述函数调用所需信息包括函数名、相关的类名,还包括相关参数;将函数调用所需信息转化为设定格式的字符串包括:创建到所述远程服务端的连接实例;创建关联所述连接实例的特定类的代理对象;调用函数;将所述特定类的类名、所述函数的函数名和相关参数进行数据打包,转化为设定格式的字符串。其中,所述特定类与所述函数相关联。
在另一些示意性实施例中,所述基于C++语言的远程函数调用方法包括:接收远程客户端发送的设定格式的字符串;解析所述字符串获得函数调用所需信息;调用本地函数。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名;其中,所述函数名用于获取函数地址,所述相关的类名用于创建类实例。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数;所述调用本地函数,包括:根据所述相关的类名创建类实例;根据所述函数名,利用所述类实例调用本地函数并传递所述相关参数。
本发明的另一个目的是提供一种通信装置。
在一些示意性实施例中,所述通信装置包括信息收发单元和中央处理单元,其中,所述中央处理单元包括接收函数调用指令的第一单元,和,将函数调用所需信息转化为设定格式的字符串的第二单元;所述设定格式 的字符串通过所述信息收发单元被发送到远程服务端。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名,所述相关的类名被所述远程服务端用于创建类实例,所述函数名被所述远程服务端用于获取函数地址。
在一些可选实施例中,所述第二单元包括创建到所述远程服务端的连接实例的第一子单元,创建关联所述连接实例的特定类的代理对象的第二子单元,和,调用函数并将所述特定类的类名和所述函数的函数名进行数据打包转化为设定格式的字符串的第三子单元。其中,所述特定类与所述函数相关联。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数;所述第二单元包括创建到所述远程服务端的连接实例的第一子单元,创建关联所述连接实例的特定类的代理对象的第二子单元,和,调用函数并将所述特定类的类名、所述函数的函数名及所述相关参数进行数据打包转化为设定格式的字符串的第四子单元。其中,所述特定类与所述函数相关联。
在另一些示意性实施例中,所述通信装置包括信息收发单元和中央处理单元,其中,所述信息收发单元用于接收远程客户端发送的设定格式的字符串;所述中央处理单元包括解析所述字符串获得函数调用所需信息的第四单元,和,调用本地函数的第五单元。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名。其中,所述函数名用于获取函数地址,所述相关的类名用于创建类实例。
在一些可选实施例中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数;所述第五单元包括根据所述类名创建类实例的第五子单元,和,根据所述函数名,利用所述类实例调用本地函数并传递所述相关参数的第七子单元。
用户在客户端基于C++语言调用函数时,采用上述实施例提供的技术方案,能够将用户在客户端调用函数的行为转化为向远程服务端发送包含函数调用信息的字符串的行为。通过客户端发送的字符串,服务端能够获得函数调用的相关信息并调用本地函数,从而使客户端能够基于C++语言 进行远程调用函数。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本发明。
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本发明的实施例,并与说明书一起用于解释本发明的原理。
图1是根据一示例性实施例示出的基于C++语言的远程函数调用的方法的流程示意图;
图2是根据另一示例性实施例示出的基于C++语言的远程函数调用的方法的流程示意图;
图3a、图3b是根据一应用实施例示出的基于C++语言的远程函数调用的方法的流程示意图;
图4是根据一示例性实施例示出的一种通信装置的框图
图5是根据另一示例性实施例示出的一种通信装置的框图。
以下描述和附图充分地示出本发明的具体实施方案,以使本领域的技术人员能够实践它们。其他实施方案可以包括结构的、逻辑的、电气的、过程的以及其他的改变。实施例仅代表可能的变化。除非明确要求,否则单独的部件和功能是可选的,并且操作的顺序可以变化。一些实施方案的部分和特征可以被包括在或替换其他实施方案的部分和特征。本发明的实施方案的范围包括权利要求书的整个范围,以及权利要求书的所有可获得的等同物。在本文中,各实施方案可以被单独地或总地用术语“发明”来表示,这仅仅是为了方便,并且如果事实上公开了超过一个的发明,不是要自动地限制该应用的范围为任何单个发明或发明构思。本文中,诸如第一和第二等之类的关系术语仅仅用于将一个实体或者操作与另一个实体或操作区分开来,而不要求或者暗示这些实体或操作之间存在任何实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法或者设备不仅包 括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法或者设备中还存在另外的相同要素。本文中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的方法、产品等而言,由于其与实施例公开的方法部分相对应,所以描述的比较简单,相关之处参见方法部分说明即可。
图1示出一个基于C++语言的远程函数调用的示意性流程。
在该示意性实施例中,所述远程函数调用的方法包括:接收函数调用指令(步骤S11),将函数调用所需信息转化为设定格式的字符串(S12),发送设定格式的字符串到远程服务端(S13)。其中,所述设定格式的字符串被远程服务端用于调用本地函数。
用户在客户端基于C++语言编写程序时,当用户在客户端调用函数时,采用本实施例提供的示意性流程,能够将函数调用行为转化为向远程服务端发送字符串的行为。通过客户端发送的字符串,服务端能够获得函数调用的相关信息并调用本地函数,从而使客户端能够基于C++语言进行远程调用函数。
在一些可选实施方式中,函数调用所需信息包括函数名和相关的类名。所述设定格式的字符串也包含函数名和相关的类名。将函数调用所需信息转化为设定格式的字符串包括:创建到所述远程服务端的连接实例;创建关联所述连接实例的特定类的代理对象;调用函数;将所述特定类的类名和所述函数的函数名进行数据打包,转化为设定格式的字符串。在一些可选实施方式中,所述特定类与所述函数相关联。
通过客户端发送的字符串,服务端能够获得函数名和相关的类名,进而能够创建类实例、获取函数地址并调用本地函数,从而使客户端能够基于C++语言进行远程调用函数。
在一些可选实施方式中,函数调用所需信息包括函数名和相关的类名,还包括相关参数。相应地,所述设定格式的字符串也包含函数名和相关的类名,还包含相关参数。将函数调用所需信息转化为设定格式的字符串包 括:创建到所述远程服务端的连接实例;创建关联所述连接实例的特定类的代理对象;调用函数;将所述特定类的类名、所述函数的函数名和相关参数进行数据打包,转化为设定格式的字符串。在一些可选实施方式中,所述特定类与所述函数相关联。采用本实施例,通过提供包含类名、函数名和参数的字符串,不仅实现远程调用函数且支持函数变长参数,解决了服务端接收到函数调用请求数据后无法转换为函数调用的问题。
在一些可选实施方式中,发送所述设定格式的字符串到远程服务端后,还包括:接收所述远程服务端发送的函数调用结果。
图2示出另一个基于C++语言的远程函数调用的示意性流程。
在该示意性实施例中,所述远程函数调用的方法包括:接收远程客户端发送的设定格式的字符串(步骤S21),解析所述字符串获得函数调用所需信息(步骤S22),调用本地函数(步骤S23)。
在一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名,其中,函数名用于获取函数地址,相关的类名用于创建类实例。所述调用本地函数,包括:根据所述函数名,利用所述类实例调用本地函数。
在一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数,所述相关参数被用于函数调用。所述调用本地函数,包括:根据所述函数名,利用所述类实例调用本地函数并传递所述相关参数。
在一些可选实施方式中,调用本地函数后还包括:将函数调用结果发送给所述远程客户端。
在一个应用场景中,用户的主机作为客户端通过网络连接到机器人服务端,用户在自己的主机上利用提供的SDK编写需要实现的功能代码,例如控制机器人前进。函数调用的部分伪代码如表1所示。
表1基于C++的远程函数调用部分伪代码
在该应用场景中,SDK将前进函数forward()的调用过程转化为向机器 人服务端发送字符串的行为,示意性的流程如图3a所示。
步骤S311,接收前进函数forward()的调用指令。
步骤S312,创建到机器人服务端的连接实例broker。
步骤S313,创建关联所述连接实例的动作类代理对象motionProxy。
步骤S314,调用前进函数proxy.forward()。
需要说明的是,控制机器人前进是控制机器人做出前进的动作,属于控制机器人做出动作,因此在创建代理对象时需要创建动作类代理对象。即,代理对象的类与所调用的函数之间具有关联性。在其它场景中,例如控制机器人进行语音识别或图像识别,在调用语音识别函数或图像识别函数时,代理对象的类将随之改变,例如为识别类代理对象,而不是动作类代理对象。
步骤S315,调用C++中通用的函数Callfunction将类名“motionProxy”、函数名“forward()”及参数列表进行数据打包,转化为设定格式的字符串。
步骤S316,发送设定格式的字符串到机器人服务端。
步骤S317,等待机器人服务端返回函数调用的结果。
机器人服务端接收字符串并调用函数的示意性流程如图3b所示。
步骤S321,接收客户端主机发送的设定格式的字符串;
步骤S322,解析字符串获得函数名“forward()”、类名“motionProxy”和参数列表。
步骤S323,根据类名“motionProxy”创建类实例。可选的部分可供参考的伪代码包括“instance=new motionProxy”。
步骤S324,根据函数名“forward()”,利用类实例调用本地函数并传递参数列表。可选的部分可供参考的伪代码包括“instance->forward(params)”。
步骤S325,将函数调用结果发送给客户端主机。
图4示出一个可选的通信装置的示意性结构。
该示意性实施例中,所述通信装置包括信息收发单元S1和中央处理单元S2,所述中央处理单元S2包括第一单元S201和第二单元S202。
第一单元S201用于接收函数调用指令。第二单元S202用于将函数调用所需信息转化为设定格式的字符串。信息收发单元S1将所述设定格式的字符串发送到远程服务端。
在一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名。其中,所述函数名被所述远程服务端用于获取函数地址,所述相关的类名被所述远程服务端用于创建类实例。第二单元S202包括创建到所述远程服务端的连接实例的第一子单元,创建关联所述连接实例的特定类的代理对象的第二子单元,和,调用函数并将所述特定类的类名和所述函数的函数名进行数据打包转化为设定格式的字符串的第三子单元。其中,所述特定类与所述本地函数相关联。
在另一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数。第二单元S202包括创建到所述远程服务端的连接实例的第一子单元,创建关联所述连接实例的特定类的代理对象的第二子单元,和,调用函数并将所述特定类的类名、所述函数的函数名及所述相关参数进行数据打包转化为设定格式的字符串的第四子单元。
在一些可选实施方式中,所述信息收发单元还用于在发送所述设定格式的字符串到远程服务端后,接收所述远程服务端发送的函数调用结果。
图5示出另一个可选的通信装置的示意性结构。
该示意性实施例中,所述通信装置包括信息收发单元S3和中央处理单元S4。信息收发单元S3用于接收远程客户端发送的设定格式的字符串;中央处理单元S4包括第四单元S401和第五单元S402。
第四单元S401用于解析所述字符串获得函数调用所需信息,第五单元S402用于调用本地函数。
在一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名。其中,所述函数名用于获取函数地址,所述相关的类名用于创建类实例。第五单元S402包括根据所述相关的类名创建类实例的第五子单元,和,根据所述函数名,利用所述类实例调用本地函数的第六子单元。
在另一些可选实施方式中,所述函数调用所需信息包括函数名和相关的类名,还包括相关参数;所述第五单元包括根据所述相关的类名创建类实例的第五子单元,和,根据所述函数名,利用所述类实例调用本地函数并传递所述相关参数的第七子单元。
在一些可选实施方式中,信息收发单元S3还用于将函数调用结果发送给所述远程客户端。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器,上述指令可由处理器执行以完成前文所述的方法。上述非临时性计算机可读存储介质可以是只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁带和光存储设备等。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。所属技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
本文所披露的实施例中,应该理解到,所揭露的方法、产品(包括但不限于装置、设备等),可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
应当理解的是,本发明并不局限于上面已经描述并在附图中示出的流程及结构,并且可以在不脱离其范围进行各种修改和改变。本发明的范围仅由所附的权利要求来限制。
Claims (12)
- 一种基于C++语言的远程函数调用方法,其特征在于,包括:接收函数调用指令;将函数调用所需信息转化为设定格式的字符串;发送所述设定格式的字符串到远程服务端。
- 如权利要求1所述的远程函数调用方法,其特征在于,将函数调用所需信息转化为设定格式的字符串包括:创建到所述远程服务端的连接实例;创建关联所述连接实例的特定类的代理对象;调用函数;将所述特定类的类名和所述函数的函数名进行数据打包,转化为设定格式的字符串。
- 如权利要求1或2任一项所述的远程函数调用方法,其特征在于,发送所述设定格式的字符串到远程服务端后,还包括:接收所述远程服务端发送的函数调用结果。
- 一种基于C++语言的远程函数调用方法,其特征在于,包括:接收远程客户端发送的设定格式的字符串;解析所述字符串获得函数调用所需信息;调用本地函数。
- 如权利要求74所述的远程函数调用方法,其特征在于,所述调用本地函数包括:根据所述相关的类名创建类实例,并根据所述函数名,利用所述类实例调用本地函数。
- 如权利要求4或5所述的远程函数调用方法,其特征在于,还包括:将函数调用结果发送给所述远程客户端。
- 一种通信装置,包括信息收发单元和中央处理单元,其特征在于,所述中央处理单元包括接收函数调用指令的第一单元,和,将函数调用所需信息转化为设定格式的字符串的第二单元;所述设定格式的字符串通过所述信息收发单元被发送到远程服务端。
- 如权利要求7所述的通信装置,其特征在于,所述第二单元包括创建到所述远程服务端的连接实例的第一子单元,创建关联所述连接实例的特定类的代理对象的第二子单元,和,调用函数并将所述特定类的类名和所述函数的函数名进行数据打包转化为设定格式的字符串的第三子单元。
- 如权利要求7或8所述的通信装置,其特征在于,所述信息收发单元还用于在发送所述设定格式的字符串到远程服务端后,接收所述远程服务端发送的函数调用结果。
- 一种通信装置,包括信息收发单元和中央处理单元,其特征在于,所述信息收发单元用于接收远程客户端发送的设定格式的字符串;所述中央处理单元包括解析所述字符串获得函数调用所需信息的第四单元,和,调用本地函数的第五单元。
- 如权利要求10所述的通信装置,其特征在于,所述第五单元包括根据所述类名创建类实例的第五子单元,和,根据所述函数名,利用所述类实例调用本地函数的第六子单元。
- 如权利要求10或11所述的通信装置,其特征在于,所述信息收发单元还用于将函数调用结果发送给所述远程客户端。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611242018.8A CN106648935A (zh) | 2016-12-29 | 2016-12-29 | 基于c++语言的远程函数调用方法、通信装置 |
| CN201611242018.8 | 2016-12-29 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018121698A1 true WO2018121698A1 (zh) | 2018-07-05 |
Family
ID=58836206
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/119576 Ceased WO2018121698A1 (zh) | 2016-12-29 | 2017-12-28 | 基于c++语言的远程函数调用方法、通信装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN106648935A (zh) |
| WO (1) | WO2018121698A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114461411A (zh) * | 2020-11-10 | 2022-05-10 | 腾讯科技(深圳)有限公司 | 业务处理系统、方法、设备及介质 |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106648935A (zh) * | 2016-12-29 | 2017-05-10 | 深圳市优必选科技有限公司 | 基于c++语言的远程函数调用方法、通信装置 |
| CN108228365B (zh) * | 2017-12-28 | 2021-04-06 | 杭州马猴烧韭科技有限公司 | 一种函数请求发送方法、函数请求调用方法及装置 |
| CN110347522A (zh) * | 2019-07-09 | 2019-10-18 | 沈阳欧瑞科技有限公司 | 一种服务端和客户端一体化的实现方法 |
| CN111338820B (zh) * | 2020-02-24 | 2024-04-05 | 京东科技信息技术有限公司 | 运行方法、客户端及存储介质 |
| CN113535139B (zh) * | 2020-04-15 | 2025-02-11 | 北京配天技术有限公司 | 功能函数实现的方法、解释器及计算机可读存储介质 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103164270A (zh) * | 2011-12-12 | 2013-06-19 | 阿里巴巴集团控股有限公司 | java 系统应用程序编程接口调用方法及系统 |
| US20150006671A1 (en) * | 2013-06-28 | 2015-01-01 | Tencent Technology (Shenzhen) Company Limited | Method, apparatus and system for sharing webpage |
| CN106648935A (zh) * | 2016-12-29 | 2017-05-10 | 深圳市优必选科技有限公司 | 基于c++语言的远程函数调用方法、通信装置 |
-
2016
- 2016-12-29 CN CN201611242018.8A patent/CN106648935A/zh active Pending
-
2017
- 2017-12-28 WO PCT/CN2017/119576 patent/WO2018121698A1/zh not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103164270A (zh) * | 2011-12-12 | 2013-06-19 | 阿里巴巴集团控股有限公司 | java 系统应用程序编程接口调用方法及系统 |
| US20150006671A1 (en) * | 2013-06-28 | 2015-01-01 | Tencent Technology (Shenzhen) Company Limited | Method, apparatus and system for sharing webpage |
| CN106648935A (zh) * | 2016-12-29 | 2017-05-10 | 深圳市优必选科技有限公司 | 基于c++语言的远程函数调用方法、通信装置 |
Non-Patent Citations (2)
| Title |
|---|
| IRONS: "H?tti RPC (C++", 7 January 2015 (2015-01-07), pages 1, Retrieved from the Internet <URL:http://www.cnblogs.eom/irons/p/4208256.html> * |
| LINDRUD, J.: "RMI for C++", 6 August 2009 (2009-08-06), pages 1, Retrieved from the Internet <URL:https://www.codeproject.com/Articles/9524/RMI-for-C> * |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114461411A (zh) * | 2020-11-10 | 2022-05-10 | 腾讯科技(深圳)有限公司 | 业务处理系统、方法、设备及介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN106648935A (zh) | 2017-05-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018121698A1 (zh) | 基于c++语言的远程函数调用方法、通信装置 | |
| US11765243B2 (en) | Data processing method, multi-cloud management system, and related device | |
| US11025750B2 (en) | Determining whether to perform requests at a server or at a client device based on resources provided by the client device | |
| KR102490776B1 (ko) | 디지털 개인 비서 내에서 헤드리스로 작업을 완료하기 위한 기법 | |
| US10977103B2 (en) | Awakening an application by means of a mobile browser | |
| US8549471B2 (en) | Method and apparatus for providing API service and making API mash-up, and computer readable recording medium thereof | |
| US20140372970A1 (en) | Method to auto generate jax-rs rest service implementation classes from existing interfaces | |
| US10930288B2 (en) | Mobile device for speech input and text delivery | |
| WO2013101770A1 (en) | Virtual channel for embedded process communication | |
| CN106874174A (zh) | 接口测试及功能测试的实现方法和装置 | |
| CN108027725B (zh) | 指导终端设备操作的方法、装置和设备 | |
| US12401725B2 (en) | Communication system for micro-frontends of a web application | |
| CA3072964C (en) | Processor-implemented method, computing system and computer program for invoking a search | |
| US20150067013A1 (en) | Methods for servicing web service requests using parallel agile web services and devices thereof | |
| US12160481B2 (en) | Dynamically configurable client application activity | |
| US20200111487A1 (en) | Voice capable api gateway | |
| CN103530329A (zh) | 一种进行网页加载的方法、装置和浏览器 | |
| US7920852B2 (en) | Compression of data transmitted between server and mobile device | |
| US20110145699A1 (en) | Annotation driven representational state transfer (rest) web services | |
| CN104065679A (zh) | 一种远程桌面操作的方法及客户端 | |
| CN114417205A (zh) | 基于资源树的页面配置方法、装置、设备以及存储介质 | |
| US10652341B2 (en) | Restful interface system for an application | |
| CN114116111B (zh) | 配置流程节点和数据处理的方法、装置、设备及介质 | |
| CN108460128A (zh) | 文档管理方法及装置、电子装置及可读存储介质 | |
| JP4949217B2 (ja) | プログラムコンポーネント呼び出しシステム、プログラムコンポーネント呼び出し方法、および、ユーザ端末 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17887214 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17887214 Country of ref document: EP Kind code of ref document: A1 |
