- Registry
- Overview
- Summary
- Files
- Data Structures
- Macros
- Typedefs
- Functions
- Details
- Macro Definition Documentation
- INHERIT_CLIENT_IPROXY
- INHERIT_IPROXY_ENTRY
- INHERIT_SERVER_IPROXY
- IPROXY_END
- SERVER_IPROXY_BEGIN
- SERVER_PROXY_VER
- Typedef Documentation
- Creator
- Destroyer
- INotify
- Function Documentation
- SAMGR_GetRemoteIdentity()
- SAMGR_RegisterFactory()
Registry
Overview
Provides APIs for registering and discovering inter-process communication (IPC) capabilities.
Based on the Samgr development framework, this module helps you to develop system capabilities and implement cross-process calls. This module is used when system capabilities need to be provided across processes.
Since:
1.0
Version:
1.0
Summary
Files
Provides basic APIs for remote service registration and discovery. |
Data Structures
Macros
Defines the end of the default initialization for the server proxy class. |
|
SERVER_PROXY_VER 0x80 |
|
Defines the beginning of the default initialization for the server proxy class. |
Typedefs
INotify) (IOwner owner, int code, IpcIo reply) |
|
Creator) (const char service, const char feature, uint32 size) |
|
Destroyer) (const char service, const char feature, void iproxy) |
Functions
SAMGR_GetRemoteIdentity (const char service, const char feature) |
Obtains the IPC address of a remote service and feature based on the service name and feature name. |
SAMGR_RegisterFactory (const char service, const char feature, Creator creator, Destroyer destroyer) |
Registers the factory method of the client proxy object with the Samgr. |
Details
Macro Definition Documentation
INHERIT_CLIENT_IPROXY
#define INHERIT_CLIENT_IPROXY
Values: [INHERIT_IUNKNOWN](Samgr.md#gab74532a22d6993d0ffc014d36253397f); \
int (*Invoke)([IClientProxy]($api-api-SmartVision-Devices-IClientProxy.md) *proxy, int funcId, IpcIo *request, IOwner owner, [INotify]($api-api-SmartVision-Devices-Registry.md#ga362a17c1bda1aace88d42dcbc88bdfac) notify)
Description:
Indicates the inherited macro of the client proxy.
This constant is used when a client proxy needs to be customized or generated by a tool.
INHERIT_IPROXY_ENTRY
#define INHERIT_IPROXY_ENTRY( T) [INHERIT_IUNKNOWNENTRY]($api-api-SmartVision-Devices-Samgr.md#gad6324fd90dd636180efa2a59b377e65c)(T)
Description:
Inherits the server proxy class.
When the server provides cross-process system capabilities, it uses INHERIT_IPROXY_ENTRY to define the server proxy class.
INHERIT_SERVER_IPROXY
#define INHERIT_SERVER_IPROXY
Values: [INHERIT_IUNKNOWN](Samgr.md#gab74532a22d6993d0ffc014d36253397f); \
int32 (*Invoke)([IServerProxy]($api-api-SmartVision-Devices-IServerProxy.md) *iProxy, int funcId, void *origin, IpcIo *req, IpcIo *reply)
Description:
Inherits the server proxy function.
When the server provides cross-process system capabilities, it uses INHERIT_SERVER_IPROXY to define the server proxy function.
IPROXY_END
#define IPROXY_END [IUNKNOWN_ENTRY_END]($api-api-SmartVision-Devices-Samgr.md#ga4ef734474ece49aa938d8ebd5b54bdb3)
Description:
Defines the end of the default initialization for the server proxy class.
This macro is used for developing the server proxy class. You can inherit this macro to reduce the code amount and prevent class definition inconsistency.
SERVER_IPROXY_BEGIN
#define SERVER_IPROXY_BEGIN [IUNKNOWN_ENTRY_BEGIN]($api-api-SmartVision-Devices-Samgr.md#ga52ec6b5b03d56b0dfe7277785246bda1)([SERVER_PROXY_VER]($api-api-SmartVision-Devices-Registry.md#gad513d97bfb873f27c9b8f69a5a418d55))
Description:
Defines the beginning of the default initialization for the server proxy class.
This macro is used for developing the server proxy class. You can inherit this macro to reduce the code amount and prevent class definition inconsistency.
SERVER_PROXY_VER
#define SERVER_PROXY_VER 0x80
Description:
Defines the default version number of the server proxy.
The cross-process system capabilities are registered when Samgr uses SERVER_PROXY_VER to query the registered server proxy.
Typedef Documentation
Creator
typedef void*(* Creator) (const char *service, const char *feature, uint32 size)
Description:
Indicates the creator of the customized client proxy.
This macro creates a local client proxy for remote service APIs. If you want to call the remote APIs in the way that local APIs are called, implement this macro to encapsulate serialized data into the proxy. The system automatically calls this macro when creating a proxy object.
Parameters:
service | Indicates the pointer to the name of the service to which the function belongs. |
feature | Indicates the pointer to the name of the feature to which the function belongs. |
size | Indicates the size of the head to be added when a client proxy is created. The required memory capacity is the head size plus the object size. |
Returns:
void * Returns the applied memory capacity and initialize the memory for the client proxy.
Destroyer
typedef void(* Destroyer) (const char *service, const char *feature, void *iproxy)
Description:
Indicates the destroyer of the customized client proxy.
This macro destroys local client proxy for remote service APIs. If you want to call the remote APIs in the way that local APIs are called, implement this macro to encapsulate serialized data into the proxy. The system automatically calls this macro when destroying a proxy object.
Parameters:
INotify
typedef int(* INotify) (IOwner owner, int code, IpcIo *reply)
Description:
Called when a client request is responded.
The client implements this INotify callback to receive response data from the server. owner indicates the client proxy that receives the response data; code indicates the error code of the response data from the server; reply indicates the response data.
Function Documentation
SAMGR_GetRemoteIdentity()
SvcIdentity SAMGR_GetRemoteIdentity (const char * service, const char * feature )
Description:
Obtains the IPC address of a remote service and feature based on the service name and feature name.
This function is used when IClientProxy cannot meet your requirements for calling IPCs. For example, if you need to receive the death notification of a remote service or feature, you can call this function to obtain the address of the remote service or feature and subscribe to the death notification from the IPC.
Parameters:
service | Indicates the pointer to the name of the remote service. |
feature | Indicates the pointer to the name of the remote feature. |
Returns:
Returns the IPC address of the remote service or feature. When the handle of the obtained address structure SvcIdentity is 0xFFFFFFFF, the address is invalid.
Attention:
This function can be called only after GetFeatureApi in SamgrLite is successfully called. Otherwise, an invalid address is returned. When the service or feature does not support IPC communication, an invalid address will be returned.
SAMGR_RegisterFactory()
int SAMGR_RegisterFactory (const char * service, const char * feature, [Creator]($api-api-SmartVision-Devices-Registry.md#ga0c8aa2ef9883bd97b4f1309895adaa4c) creator, [Destroyer]($api-api-SmartVision-Devices-Registry.md#ga1e6298b1246357f70ad0b581e0eb9305) destroyer )
Description:
Registers the factory method of the client proxy object with the Samgr.
If you want to call the remote APIs in the way that local APIs are called, implement this function to encapsulate serialized data into the proxy. During system initialization, the module that uses the remote proxy calls the function as required.
Parameters:
Returns:
Returns EC_SUCCESS if the registration is successful; returns other error codes if the registration fails.