Updated on 2022-03-13 GMT+08:00

Graph::SetDataRecvFunctor

Sets the callback function for an engine in the graph to receive messages. The running environment of the code that calls the API must be the same as that of the engine. For example, if the engine runs on the device side, the code that calls the function must also run in the device side. This API is defined in graph.h.

This API, which must be used together with the DataRecvInterface::RecvData API, is generally used to return the inference result to the user. The detailed principles are as follows:

  1. Define a subclass (for example, DdkDataRecvInterface) of class DataRecvInterface and initialize the object of the subclass.
  2. Set the object of class DdkDataRecvInterface to a callback function by calling Graph::SetDataRecvFunctor.
  3. Send the input data to the corresponding output port by calling Engine::SendData.
  4. Return the inference result by calling the RecvData function of class DdkDataRecvInterface.

Syntax

static HIAI_StatusT Graph::SetDataRecvFunctor(const EnginePortID& targetPortConfig, const std::shared_ptr<DataRecvInterface>& dataRecv);

Parameter Description

Parameter

Description

Value Range

targetPortConfig

Graph ID, engine ID, and port ID of the data receiver

-

dataRecv

Callback function for receiving user-defined data

-

Return Value

For details about the returned error codes, see "Error Codes."

Error Codes

No.

Error Code

Description

1

HIAI_OK

The running is OK.

2

HIAI_PORT_ID_ERROR

The port ID has an error.