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 PLUGIN_H 17 #define PLUGIN_H 18 19 #include <string> 20 21 #include "plugin/i_plugin.h" 22 23 namespace OHOS { 24 namespace AI { 25 class Plugin { 26 public: 27 /** 28 * Initialize plugin 29 * 30 * @param [in] aid Algorithm id 31 * @param [in] version Algorithm version 32 */ 33 Plugin(const std::string &aid, long long version); 34 35 /** 36 * Destructor of plugin 37 */ 38 virtual ~Plugin(); 39 40 /** 41 * Get algorithm of plugin 42 * 43 * @return Algorithm handler 44 */ 45 IPlugin *GetPluginAlgorithm(); 46 47 /** 48 * Set algorithm of plugin 49 * 50 * @param [in] pluginAlgorithm Algorithm handler 51 */ 52 void SetPluginAlgorithm(IPlugin *pluginAlgorithm); 53 54 /** 55 * Load algorithm 56 * 57 * @return Returns RETCODE_SUCCESS(0) if the operation is successful, returns a non-zero value otherwise. 58 */ 59 int LoadPluginAlgorithm(); 60 61 /** 62 * Unload algorithm 63 */ 64 void UnloadPluginAlgorithm(); 65 66 /** 67 * Get algorithm version 68 * 69 * @return Algorithm version 70 */ 71 long long GetVersion() const; 72 73 /** 74 * Get algorithm id 75 * 76 * @return Algorithm id 77 */ 78 std::string GetAid() const; 79 80 private: 81 IPlugin *pluginAlgorithm_ {nullptr}; 82 std::string aid_ {""}; 83 long long version_ {0}; 84 void *handle_ {nullptr}; 85 }; 86 } // namespace AI 87 } // namespace OHOS 88 89 #endif // PLUGIN_H