1 /* 2 * Copyright (c) 2022 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 THERMAL_HDF_CONFIG_H 17 #define THERMAL_HDF_CONFIG_H 18 19 #include <string> 20 #include <vector> 21 #include <memory> 22 #include <map> 23 #include <libxml/xpath.h> 24 #include <libxml/tree.h> 25 #include <libxml/parser.h> 26 27 #include "base_info_config.h" 28 #include "sensor_info_config.h" 29 30 namespace OHOS { 31 namespace HDI { 32 namespace Thermal { 33 namespace V1_0 { 34 struct XMLThermal { 35 std::string version; 36 std::string product; 37 }; 38 39 class ThermalHdfConfig { 40 public: 41 using ThermalTypeMap = std::map<std::string, std::shared_ptr<SensorInfoConfig>>; ThermalHdfConfig()42 ThermalHdfConfig() {}; 43 ~ThermalHdfConfig() = default; 44 ThermalHdfConfig(const ThermalHdfConfig&) = delete; 45 ThermalHdfConfig& operator=(const ThermalHdfConfig&) = delete; 46 static ThermalHdfConfig &GetInsance(); 47 48 int32_t ThermalHDIConfigInit(const std::string &path); 49 int32_t ParseThermalHdiXMLConfig(const std::string &path); 50 void ParseBaseNode(xmlNodePtr node); 51 void ParsePollingNode(xmlNodePtr node); 52 void ParseConfigInfo(const xmlNode *cur, std::vector<XMLThermalZoneInfo> &tzInfoList, 53 std::vector<XMLThermalNodeInfo> &tnInfoList); 54 ThermalTypeMap GetSensorTypeMap(); SetSensorTypeMap(const ThermalTypeMap & typesMap)55 void SetSensorTypeMap(const ThermalTypeMap& typesMap) 56 { 57 typesMap_ = typesMap; 58 } 59 void GetThermalZoneNodeInfo(XMLThermalZoneInfo &tz, const xmlNode* node); GetBaseConfig()60 std::shared_ptr<BaseInfoConfig> GetBaseConfig() 61 { 62 return baseConfig_; 63 } 64 private: 65 std::shared_ptr<BaseInfoConfig> baseConfig_; 66 ThermalTypeMap typesMap_; 67 XMLThermal thermal_; 68 }; 69 } // V1_0 70 } // Thermal 71 } // HDI 72 } // OHOS 73 74 #endif // THERMAL_HDF_CONFIG_H