1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Registry 18 * @{ 19 * 20 * @brief Provides APIs for registering and discovering inter-process communication (IPC) 21 * capabilities. 22 * 23 * Based on the Samgr development framework, this module helps you to develop system capabilities 24 * and implement cross-process calls. \n 25 * This module is used when system capabilities need to be provided across processes. \n 26 * 27 * @since 1.0 28 * @version 1.0 29 */ 30 31 /** 32 * @file registry.h 33 * 34 * @brief Provides basic APIs for remote service registration and discovery. 35 * 36 * APIs provided by this file include the factory registration function of the client code. \n 37 * This file is used when there are customized client objects. \n 38 * 39 * @since 1.0 40 * @version 1.0 41 */ 42 #ifndef LITE_REGISTRY_H 43 #define LITE_REGISTRY_H 44 45 #include <ohos_types.h> 46 #include <iunknown.h> 47 48 #ifdef __cplusplus 49 #if __cplusplus 50 extern "C" { 51 #endif 52 #endif 53 54 /** 55 * @brief Indicates the creator of the customized client proxy. 56 * 57 * This macro creates a local client proxy for remote service APIs. 58 * If you want to call the remote APIs in the way that local APIs are called, implement this macro 59 * to encapsulate serialized data into the proxy. \n 60 * The system automatically calls this macro when creating a proxy object. \n 61 * 62 * @param service Indicates the pointer to the name of the service to which the function belongs. 63 * @param feature Indicates the pointer to the name of the feature to which the function belongs. 64 * @param size Indicates the size of the head to be added when a client proxy is created. The 65 * required memory capacity is the head size plus the object size. 66 * @return void * Returns the applied memory capacity and initialize the memory for the client 67 * proxy. 68 */ 69 typedef void *(*Creator)(const char *service, const char *feature, uint32 size); 70 71 /** 72 * @brief Indicates the destroyer of the customized client proxy. 73 * 74 * This macro destroys local client proxy for remote service APIs. 75 * If you want to call the remote APIs in the way that local APIs are called, implement this macro 76 * to encapsulate serialized data into the proxy. \n 77 * The system automatically calls this macro when destroying a proxy object. \n 78 * 79 * @param service Indicates the pointer to the name of the service to which the function belongs. 80 * @param feature Indicates the pointer to the name of the feature to which the function belongs. 81 * @param iproxy Indicates the pointer to the start address of the memory that is applied by 82 * <b>Creator</b>. 83 */ 84 typedef void (*Destroyer)(const char *service, const char *feature, void *iproxy); 85 86 /** 87 * @brief Registers the factory method of the client proxy object with the Samgr. 88 * 89 * 90 * If you want to call the remote APIs in the way that local APIs are called, implement this 91 * function to encapsulate serialized data into the proxy. \n 92 * During system initialization, the module that uses the remote proxy calls the function as 93 * required. \n 94 * 95 * @param service Indicates the pointer to the service name of the client proxy. 96 * @param feature Indicates the pointer to the feature name of the client proxy. 97 * @param creator Indicates the <b>Creator</b> function of the client proxy. 98 * @param destroyer Indicates the <b>Destroyer</b> function of the client proxy. 99 * @return Returns <b>EC_SUCCESS</b> if the registration is successful; returns other error codes 100 * if the registration fails. 101 * @since 1.0 102 * @version 1.0 103 */ 104 int SAMGR_RegisterFactory(const char *service, const char *feature, Creator creator, Destroyer destroyer); 105 #ifdef __cplusplus 106 #if __cplusplus 107 } 108 #endif 109 #endif 110 #endif // LITE_REGISTRY_H 111 /** @} */ 112