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 RESSCHED_SERVICES_RESSCHEDMGR_RESSCHEDFWK_INCLUDE_PLUGIN_SWITCH_H 17 #define RESSCHED_SERVICES_RESSCHEDMGR_RESSCHEDFWK_INCLUDE_PLUGIN_SWITCH_H 18 19 #include <memory> 20 #include <mutex> 21 #include "config_info.h" 22 #include "libxml/parser.h" 23 #include "libxml/xpath.h" 24 25 namespace OHOS { 26 namespace ResourceSchedule { 27 struct PluginInfo { 28 std::string libPath; 29 bool switchOn = false; 30 }; 31 32 class PluginSwitch { 33 public: 34 /** 35 * Load the config file, parse the xml stream and construct the objects. 36 * 37 * @param configFile The xml filepath. 38 * @return Returns true if parse successfully. 39 */ 40 bool LoadFromConfigFile(const std::string& configFile); 41 42 /** 43 * Get all plugin info, about plugin switch status. 44 * 45 * @return Returns the plugin info. 46 */ 47 std::list<PluginInfo> GetPluginSwitch(); 48 49 private: 50 static bool IsInvalidNode(const xmlNode& currNode); 51 52 using PluginInfoMap = std::map<std::string, std::string>; 53 54 std::list<PluginInfo> pluginInfoList_; 55 }; 56 } // namespace ResourceSchedule 57 } // namespace OHOS 58 59 #endif // RESSCHED_SERVICES_RESSCHEDMGR_RESSCHEDFWK_INCLUDE_PLUGIN_SWITCH_H 60