1 /* 2 * Copyright (c) 2021 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 #ifndef I_RESPONSE_H 17 #define I_RESPONSE_H 18 19 #include <string> 20 21 #include "protocol/retcode_inner/aie_retcode_inner.h" 22 #include "protocol/struct_definition/aie_info_define.h" 23 #include "utils/aie_macros.h" 24 25 namespace OHOS { 26 namespace AI { 27 class IRequest; 28 29 class IResponse { 30 FORBID_COPY_AND_ASSIGN(IResponse); 31 FORBID_CREATE_BY_SELF(IResponse); 32 public: 33 /** 34 * Plugins prohibit the use of new, so add a create method here. 35 * 36 * @return A response object. 37 */ 38 static IResponse *Create(IRequest *request); 39 40 /** 41 * Destroy response method. 42 * 43 * @param [in,out] response Destroyed response object. 44 */ 45 static void Destroy(IResponse *&response); 46 47 /** 48 * Get request Id. 49 * 50 * @return Request Id. 51 */ 52 int GetRequestId() const; 53 54 /** 55 * Get request transaction Id. 56 * 57 * @return Request transaction Id. 58 */ 59 long long GetTransactionId() const; 60 61 /** 62 * Set request transaction Id. 63 * 64 * @param [in] transactionId Transaction Id. 65 */ 66 void SetTransactionId(long long transactionId); 67 68 /** 69 * Get algorithm plugin type. 70 * 71 * @return Algorithm plugin type. 72 */ 73 int GetAlgoPluginType() const; 74 75 /** 76 * Set algorithm plugin type. 77 * 78 * @param [in] type Algorithm plugin type. 79 */ 80 void SetAlgoPluginType(int type); 81 82 /** 83 * Get response return code. 84 * 85 * @return Response return code. 86 */ 87 int GetRetCode() const; 88 89 /** 90 * Set response return code. 91 * 92 * @param [in] retCode Response return code. 93 */ 94 void SetRetCode(int retCode); 95 96 /** 97 * Get client uid. 98 * 99 * @return Client uid. 100 */ 101 uid_t GetClientUid() const; 102 103 /** 104 * Set client uid. 105 * 106 * @param [in] clientUid Client uid. 107 */ 108 void SetClientUid(const uid_t clientUid); 109 110 /** 111 * Get response return description. 112 * 113 * @return Response return description. 114 */ 115 const std::string &GetRetDesc() const; 116 117 /** 118 * Set response return description. 119 * 120 * @param [in] retDesc Response return description. 121 */ 122 void SetRetDesc(const std::string &retDesc); 123 124 /** 125 * Get response result. 126 * 127 * @return Response result. 128 */ 129 const DataInfo &GetResult() const; 130 131 /** 132 * Set response result. 133 * 134 * @param [in] result Response result. 135 */ 136 void SetResult(const DataInfo &result); 137 138 /** 139 * detach DataInfo data ptr 140 */ 141 void Detach(); 142 }; 143 } // namespace AI 144 } // namespace OHOS 145 146 #endif // I_RESPONSE_H 147