• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_ROSEN_DISPLAY_MANAGER_CONFIG_H
17 #define OHOS_ROSEN_DISPLAY_MANAGER_CONFIG_H
18 
19 #include <map>
20 #include <refbase.h>
21 #include <string>
22 #include <vector>
23 
24 #include "libxml/parser.h"
25 
26 namespace OHOS::Rosen {
27 class DisplayManagerConfig : public RefBase {
28 public:
29     DisplayManagerConfig() = delete;
30     ~DisplayManagerConfig() = default;
31 
32     static bool LoadConfigXml();
33     static const std::map<std::string, bool>& GetEnableConfig();
34     static const std::map<std::string, std::vector<int>>& GetIntNumbersConfig();
35     static const std::map<std::string, std::string>& GetStringConfig();
36     static void DumpConfig();
37 
38 private:
39     static std::map<std::string, bool> enableConfig_;
40     static std::map<std::string, std::vector<int>> intNumbersConfig_;
41     static std::map<std::string, std::string> stringConfig_;
42 
43     static bool IsValidNode(const xmlNode& currNode);
44     static void ReadEnableConfigInfo(const xmlNodePtr& currNode);
45     static void ReadIntNumbersConfigInfo(const xmlNodePtr& currNode);
46     static void ReadStringConfigInfo(const xmlNodePtr& currNode);
47     static std::string GetConfigPath(const std::string& configFileName);
48 
49     static std::vector<std::string> Split(std::string str, std::string pattern);
50     static inline bool IsNumber(std::string str);
51 };
52 } // namespace OHOS::Rosen
53 #endif // OHOS_ROSEN_DISPLAY_MANAGER_CONFIG_H
54