1 /*
2  * Copyright (c) 2024 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 #ifndef PLUGIN_MANAGER_H
16 #define PLUGIN_MANAGER_H
17 
18 #include <string>
19 #include <unordered_map>
20 #include <js_native_api.h>
21 #include <js_native_api_types.h>
22 #include <ace/xcomponent/native_interface_xcomponent.h>
23 
24 #include "plugin_render.h"
25 
26 namespace OHOS {
27 class PluginManager {
28 public:
29     ~PluginManager();
30 
GetInstance()31     static PluginManager *GetInstance()
32     {
33         return &PluginManager::pluginmanager_;
34     }
35 
36     void SetNativeXComponent(std::string &id, OH_NativeXComponent *nativeXComponent);
37     PluginRender *GetRender(std::string &id);
38     void Export(napi_env env, napi_value exports);
39 
40 private:
41     static PluginManager pluginmanager_;
42 
43     std::unordered_map<std::string, OH_NativeXComponent *> nativeXComponentMap_;
44     std::unordered_map<std::string, PluginRender *> pluginrendermap_;
45 };
46 } // namespace OHOS
47 #endif // PLUGIN_MANAGER_H
48