加入收藏
举报
02-14 20:02
#0
文件名称:
Registry.md
所在目录:
Openharmony v1.0 / docs / api / api-SmartVision-Devices
文件大小:
24.17 KB
下载地址:
fenwii/OpenHarmony
   
免责声明:本网站仅提供指向 GitHub 上的文件的链接,所有文件的版权归原作者所有,本网站不对文件内容的合法性、准确性或安全性承担任何责任。
文本预览:
# 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















File Name


Description


iproxy_client.h


Provides the client proxy class.


iproxy_server.h


Provides the server proxy.


registry.h


Provides basic APIs for remote service registration and discovery.



## Data Structures












Data Structure Name


Description


IClientProxy


Defines the client proxy object.


IServerProxy


Defines the base class of the server proxy object.



## Macros
























Macro Name and Value


Description


INHERIT_CLIENT_IPROXY


Indicates the inherited macro of the client proxy.


INHERIT_IPROXY_ENTRY(T)   INHERIT_IUNKNOWNENTRY(T)


Inherits the server proxy class.


IPROXY_END   IUNKNOWN_ENTRY_END


Defines the end of the default initialization for the server proxy class.


SERVER_PROXY_VER   0x80


Defines the default version number of the server proxy.


INHERIT_SERVER_IPROXY


Inherits the server proxy function.


SERVER_IPROXY_BEGIN   IUNKNOWN_ENTRY_BEGIN(SERVER_PROXY_VER)


Defines the beginning of the default initialization for the server proxy class.



## Typedefs















Typedef Name


Description


INotify) (IOwner owner, int code, IpcIo *reply)


typedef int(* 


Called when a client request is responded.


Creator) (const char *service, const char *feature, uint32 size)


typedef void *(* 


Indicates the creator of the customized client proxy.


Destroyer) (const char *service, const char *feature, void *iproxy)


typedef void(* 


Indicates the destroyer of the customized client proxy.



## Functions












Function Name


Description


SAMGR_GetRemoteIdentity (const char *service, const char *feature)


SvcIdentity 


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)


int 


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](IClientProxy.md) *proxy, int funcId, IpcIo *request, IOwner owner, [INotify](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](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](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](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](Samgr.md#ga52ec6b5b03d56b0dfe7277785246bda1)([SERVER_PROXY_VER](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:**















Name


Description


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:**















Name


Description


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.
iproxy Indicates the pointer to the start address of the memory that is applied by Creator.

## 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](IClientProxy.md) 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:**












Name


Description


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](SamgrLite.md) 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](Registry.md#ga0c8aa2ef9883bd97b4f1309895adaa4c) creator, [Destroyer](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:**


















Name


Description


service Indicates the pointer to the service name of the client proxy.
feature Indicates the pointer to the feature name of the client proxy.
creator Indicates the Creator function of the client proxy.
destroyer Indicates the Destroyer function of the client proxy.

**Returns:**
Returns **EC\_SUCCESS** if the registration is successful; returns other error codes if the registration fails.
点赞 回复
回帖
支持markdown部分语法 ?