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 PARA_CONFIG_H 17 #define PARA_CONFIG_H 18 19 #include <string> 20 #include <map> 21 #include <vector> 22 #include <memory> 23 #include <cstdlib> 24 #include "libxml/parser.h" 25 #include "libxml/tree.h" 26 #include "libxml/xpath.h" 27 #include "rme_log_domain.h" 28 #include "single_instance.h" 29 30 namespace OHOS { 31 namespace RME { 32 class ParaConfig { 33 public: 34 ParaConfig(); 35 ~ParaConfig(); 36 37 ParaConfig(const ParaConfig&) = delete; 38 ParaConfig& operator=(const ParaConfig&) = delete; 39 ParaConfig(ParaConfig&&) = delete; 40 ParaConfig& operator=(const ParaConfig&&) = delete; 41 42 static bool IsXmlPrepared(const std::string& filePath); // input parameters need gaurantee 43 static std::map<std::string, std::string> GetGeneralConfig(); 44 static std::map<std::string, std::map<std::string, int>> GetSubEventConfig(); 45 static std::vector<int> GetFpsList(); 46 static std::vector<int> GetRenderTypeList(); 47 private: 48 static std::map<std::string, std::string> m_generalConfig; 49 static std::map<std::string, std::map<std::string, int>> m_subEventConfig; 50 static std::vector<int> m_fpsList; 51 static std::vector<int> m_renderTypeList; 52 53 static void ReadAttr(xmlNodePtr& root, const std::string& attrName, std::string& res); 54 static void ReadFrameConfig(const xmlNodePtr& root); 55 static void ReadConfigInfo(const xmlNodePtr& root); 56 static void ReadFpsConfig(const xmlNodePtr& root); 57 static void ReadRenderType(const xmlNodePtr& root); 58 static void SplitString(const std::string& context, const std::string& character, 59 std::vector<int> &mList, const int maxVal, const std::string& attrName); 60 static bool IsValidNode(const xmlNode& currNode); 61 }; 62 } // namespace RME 63 } // namespace OHOS 64 #endif 65