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 THERMAL_KERNEL_CONFIG_FILE_H 17 #define THERMAL_KERNEL_CONFIG_FILE_H 18 19 #include <string> 20 #include <vector> 21 #include <memory> 22 #include <libxml/tree.h> 23 #include <libxml/parser.h> 24 #include "protector_base_info.h" 25 #include "protector_thermal_zone_info.h" 26 27 namespace OHOS { 28 namespace PowerMgr { 29 class ThermalKernelConfigFile { 30 public: 31 ~ThermalKernelConfigFile() = default; 32 ThermalKernelConfigFile(const ThermalKernelConfigFile&) = delete; 33 ThermalKernelConfigFile& operator=(const ThermalKernelConfigFile&) = delete; GetInstance()34 static ThermalKernelConfigFile &GetInstance() 35 { 36 static ThermalKernelConfigFile instance; 37 return instance; 38 } 39 40 bool Init(const std::string &path); 41 bool ParseThermalKernelXML(const std::string &path); 42 void ParserBaseNode(xmlNodePtr node); 43 void ParseControlNode(xmlNodePtr node); 44 private: 45 void ParseSubNode(xmlNodePtr cur, std::vector<ThermalZoneInfoItem>& tzItemList, std::string& type); 46 std::unique_ptr<ProtectorBaseInfo> baseInfo_; ThermalKernelConfigFile()47 ThermalKernelConfigFile() {}; 48 }; 49 } // namespace PowerMgr 50 } // namespace OHOS 51 52 #endif // THERMAL_KERNEL_CONFIG_FILE_H 53