1 /*
2  * Copyright (c) 2021-2023 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 OHOS_DISTRIBUTED_HARDWARE_IHARDWARE_HANDLER_H
17 #define OHOS_DISTRIBUTED_HARDWARE_IHARDWARE_HANDLER_H
18 
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 const std::string COMPONENT_LOADER_GET_HARDWARE_HANDLER = "GetHardwareHandler";
27 struct DHItem {
28     std::string dhId;
29     std::string attrs;
30     std::string subtype;
31 };
32 
33 class PluginListener {
34 public:
35     virtual void PluginHardware(const std::string &dhId, const std::string &attrs, const std::string &subtype) = 0;
36     virtual void UnPluginHardware(const std::string &dhId) = 0;
37 };
38 
39 class IHardwareHandler {
40 public:
41     virtual int32_t Initialize() = 0;
42     virtual std::vector<DHItem> QueryMeta() = 0;
43     virtual std::vector<DHItem> Query() = 0;
44     virtual std::map<std::string, std::string> QueryExtraInfo() = 0;
45     virtual bool IsSupportPlugin() = 0;
46     virtual void RegisterPluginListener(std::shared_ptr<PluginListener> listener) = 0;
47     virtual void UnRegisterPluginListener() = 0;
48 };
49 extern "C" __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler();
50 } // namespace DistributedHardware
51 } // namespace OHOS
52 #endif
53