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 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 }; 31 32 class PluginListener { 33 public: 34 virtual void PluginHardware(const std::string &dhId, const std::string &attrs) = 0; 35 virtual void UnPluginHardware(const std::string &dhId) = 0; 36 }; 37 38 class IHardwareHandler { 39 public: 40 virtual int32_t Initialize() = 0; 41 virtual std::vector<DHItem> Query() = 0; 42 virtual std::map<std::string, std::string> QueryExtraInfo() = 0; 43 virtual bool IsSupportPlugin() = 0; 44 virtual void RegisterPluginListener(std::shared_ptr<PluginListener> listener) = 0; 45 virtual void UnRegisterPluginListener() = 0; 46 }; 47 extern "C" __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); 48 } // namespace DistributedHardware 49 } // namespace OHOS 50 #endif 51